在Install Shield6.22下,反安装是不起作用的,在控制面板中的“添加删除程序”跟本不起作用。须要自行在注册表中写入反安装信息。在Install Shield的其它版本又没有这个问题。
1、开始菜单中增加卸载
在开始菜单中加一个ShortCut,Target设置为<DISK1TARGET>\setup.exe即可。
2、注册反安装
prototype RegUnInstall(STRING);
function RegUnInstall(szKey)
STRING svUninstLogFile;
begin
//反安装的注册
InstallationInfo(@COMPANY_NAME, @PRODUCT_NAME, @PRODUCT_VERSION, @PRODUCT_KEY);
DeinstallStart(TARGETDIR, svUninstLogFile, szKey, 0);
RegDBSetItem(REGDB_UNINSTALL_NAME, @PRODUCT_NAME);
DeinstallSetReference (TARGETDIR ^ @PRODUCT_KEY);
end;
3、设置反安装路径,用于添加/删除程序(仅用于6.22版)
prototype SetUnInstallPath();
function SetUnInstallPath()
NUMBER nResult;
STRING szProgramFolder, szItemName, szCommandLine, szWorkingDir, szIconPath;
STRING szShortCutKey, szProgram, szParam,svTmp, szKey;
begin
//写入反安装数据
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
//[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9D3ABC91-E361-4716-9529-22037C0950EF}]
szKey = "\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + PRODUCT_GUID;
szWorkingDir = WINDIR;
szProgramFolder = SHELL_OBJECT_FOLDER;
svTmp = PROGRAMFILES + "InstallShield Installation Information\\" + PRODUCT_GUID+ "\\setup.exe";
LongPathToQuote(svTmp, TRUE);
szParam = svTmp;
LongPathToShortPath(szParam);
svTmp = COMMONFILES + "InstallShield\\engine\\6\\Intel 32\\ctor.dll";
LongPathToShortPath(svTmp);
szProgram = "RunDll32" + " " + svTmp + ",LaunchSetup";
szCommandLine = szProgram + " " + szParam;
//RunDll32 D:\PROGRA~1\COMMON~1\INSTAL~1\ENGINE\6\INTEL3~1\ctor.dll,LaunchSetup "D:\Program Files\InstallShield Installation Information\PRODUCT_GUID+"\\setup.exe"
if (RegDBCreateKeyEx (szKey, "UninstallString") >= 0) then
if RegDBSetKeyValueEx (szKey, "UninstallString", REGDB_STRING, szCommandLine, -1) < 0 then
return -1;
endif;
endif;
end;