• 利用installshield实现silverlight伪WinFrom安装转


    众所周知silverlight OOB模式可以在浏览器中右键直接安装,
    我这里介绍如何把silverlight程序做成单独的EXE安装程序。
    思路:
     1.命令行安装xap
     2.安装完成删除控制面板中OOB自带的XAP的卸载
     3.installshield安装程序卸载同时也卸载silverlight程序

    准备知识:
     在看这篇文章之前需要了解silverlight部署和installshield技术。

    感谢:
     感谢我的好友FTPWMD提供installshield技术支持。

    sllauncher命令参见:
     http://tech.it168.com/a2010/0810/1088/000001088696_1.shtml

    installshield代码:

    代码
    //自定义函数
    export prototype BOOL SaveUninstall(string);
    export prototype BOOL RemoMveUninstall();
    export prototype InstallXap();
    export prototype UnInstallXap();
    export prototype CheckSilverlightAndInstall();

    //检测silverlight是否安装
    function CheckSilverlightAndInstall()
    STRING szName;
    NUMBER nReturn;
    begin

    RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
    szName
    = "SOFTWARE\\Microsoft\\Silverlight";
    nReturn
    = RegDBKeyExist(szName);
    if(nReturn<0) then
    LaunchAppAndWait (SUPPORTDIR
    ^"Silverlight.exe", "", WAIT);
    endif;

    end;

    //保存卸载信息
    function BOOL SaveUninstall(szpath)

    STRING szName, szTitle,szValue;

    NUMBER nType, nSize, nvType, nvSize;
    begin

    RegDBSetDefaultRoot ( HKEY_CURRENT_USER );

    szName
    = "UninstallString";

    nType
    = REGDB_STRING;

    nSize
    = -1;

    RegDBGetKeyValueEx (szpath, szName, nvType, szValue, nvSize) ;
      RegDBSetKeyValueEx ("SOFTWARE\\chuifeng", "UnInstall", REGDB_STRING, szValue,-1);

    end;

    //删除xap的卸载方式
    function BOOL RemoMveUninstall()
    string szKEY1, svString ,svtring1;
    LIST listSubKeys,listNames;
    NUMBER nReturn, nResult,nvItem,nLocation;
    begin

    szKEY1
    ="Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";

    listSubKeys
    = ListCreate(STRINGLIST);
    listNames
    = ListCreate(STRINGLIST);

    if ((listNames = LIST_NULL) || (listSubKeys = LIST_NULL)) then
    MessageBox (
    "Unable to create necessary lists.", SEVERE);
    abort;
    endif;

    RegDBSetDefaultRoot ( HKEY_CURRENT_USER );

    nReturn
    = RegDBQueryKey(szKEY1, REGDB_KEYS, listSubKeys );

    if (nReturn >= 0) then

    nReturn
    = ListGetFirstString (listSubKeys, svString);

    while (nReturn != END_OF_LIST)

    nLocation
    = StrFind (svString,"imd.mdrtbase.com");
    if (nLocation >= 0) then //not found

    svtring1
    =szKEY1+"\\"+svString;

    SaveUninstall(svtring1) ;

    RegDBDeleteKey (svtring1);

    return TRUE;
    endif;

    nResult
    = ListGetNextString (listSubKeys, svString);

    endwhile;

    endif;

    ListDestroy (listNames);
    ListDestroy (listSubKeys );
    end;

    //安装silverlight xap
    function InstallXap()
    string szProgram , szCmdLine ,szXapPath,szUrl,szCommd;
    begin
    szProgram
    ="C:\\Program Files\\Microsoft Silverlight\\sllauncher.exe";
    szXapPath
    = SUPPORTDIR ^"chuifeng.xap";
    szUrl
    = "http://www.chuifeng.com/ClientBin/chuifeng.xap";
    szCommd
    = " /overwrite /shortcut:desktop+startmenu";
    szCmdLine
    ="/install:\"" + szXapPath + "\""+ szCommd + " /origin:" + szUrl;
    LaunchAppAndWait (szProgram, szCmdLine, WAIT);
    end;

    //卸载silverlight xap
    function UnInstallXap()
    STRING szKey, szName, szValue, szTitle, szMsg,szCommand,szPament;

    NUMBER nType, nSize, nvType, nvSize,nvCount,nvlength;
    begin
    RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );

    szKey
    ="SOFTWARE\\chuifeng";

    szName
    = "Uninstall";

    nType
    = REGDB_STRING;

    nSize
    = -1;

    if (RegDBGetKeyValueEx (szKey, szName, nvType, szValue, nvSize) < 0) then
    MessageBox (
    "RegDBGetKeyValueEx failed.", SEVERE);
    else
    nvCount
    = StrFind (szValue, "-uninstallApp");
    StrSub (szCommand, szValue,
    0, nvCount);
    nvlength
    = StrLength(szValue);
    StrSub (szPament, szValue, nvCount,nvlength );
    LaunchAppAndWait (
    "\""+szCommand+"\"", szPament, WAIT);
    endif;
    end;
  • 相关阅读:
    synchronized 关键字
    synchronized 关键字
    Linux IPC之共享内存
    链表的插入、删除
    链式队列的实现
    链栈的实现
    双色、三色排序问题
    memmove、memcpy、strcpy、memset的实现
    字符串中去掉多余的空格
    华为机试:从一个数组中选取不同的数(均小于10)组成一个最大的三位数
  • 原文地址:https://www.cnblogs.com/chuncn/p/1915943.html
Copyright © 2020-2023  润新知