Installshield 2010 Install scrpit msi工程
最近比较蛋疼的事情是打安装包的时候,需求是最后给个chechbox供用户选择是否文件关联apk,翻阅了文件关联修改注册表,有点眉目但是没有实现功能,具体代码如下:
//设置是否关联apk,从而写注册表 export prototype ExFn_RegDBAccationKeyValueEx(); function ExFn_RegDBAccationKeyValueEx() STRING szKey, szNumName, szNumValue, svNumValue,svNumValue1,svNumValue2,svNumValue3, szTitle, szMsg,szNumName1, szNumValue1,szNumName2, szNumValue2,szNumName3, szNumValue3; NUMBER nType, nSize, nvType, nvSize; STRING szNumName4,szNumValue4,svNumValue4,szProgidKey,szNumName5,szNumValue5,svNumValue5; begin // Create a key to test. RegDBSetDefaultRoot(HKEY_CLASSES_ROOT); szKey = "MSApkInstaller\\"; if (RegDBCreateKeyEx (szKey, "") < 0) then MessageBox ("RegDBCreateKeyEx failed.", SEVERE); endif; // Set up parameters for call to RegDBSetKeyValueEx. szNumName = ""; szNumValue = TARGETDIR^"\\Resources\\logo\\MSAPK.ico,0"; nType = REGDB_STRING; nSize = -1; szNumName1 = ""; szNumValue1= "open"; szNumName2 = ""; szNumValue2= "Mobfound APk安装程序"; szNumName3 = ""; szNumValue3= "\""+TARGETDIR^"\\msApkTool.exe\" -path=\"%1\""; szKey = "MSApkInstaller\\DefaultIcon\\"; // Retrieve key value information. if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue,nvSize) < 0) then // Set a key name and a value associated with it. if (RegDBSetKeyValueEx (szKey, szNumName, nType, szNumValue,nSize) < 0) then MessageBox ("RegDBSetKeyValueEx failed.", SEVERE); else // Display what RegDBSetKeyValueEx has done. endif; endif; //we should check the key1 value1 information szKey = "MSApkInstaller\\shell\\"; if (RegDBGetKeyValueEx (szKey, szNumName1, nvType, svNumValue1,nvSize) < 0) then // Set a key name and a value associated with it. if (RegDBSetKeyValueEx (szKey, szNumName1, nType, szNumValue1,nSize) < 0) then MessageBox ("RegDBSetKeyValueEx failed1.", SEVERE); else // Display what RegDBSetKeyValueEx has done. endif; endif; //we should check the key2 value2 information szKey = "MSApkInstaller\\shell\\open\\"; if (RegDBGetKeyValueEx (szKey, szNumName2, nvType, svNumValue2,nvSize) < 0) then // Set a key name and a value associated with it. if (RegDBSetKeyValueEx (szKey, szNumName2, nType, szNumValue2,nSize) < 0) then MessageBox ("RegDBSetKeyValueEx failed2.", SEVERE); else // Display what RegDBSetKeyValueEx has done. endif; endif; //we should check the key3 value3 information szKey = "MSApkInstaller\\shell\\open\\command\\"; if (RegDBGetKeyValueEx (szKey, szNumName3, nvType, svNumValue3,nvSize) < 0) then // Set a key name and a value associated with it. if (RegDBSetKeyValueEx (szKey, szNumName3, nType, szNumValue3,nSize) < 0) then MessageBox ("RegDBSetKeyValueEx failed3.", SEVERE); else // Display what RegDBSetKeyValueEx has done. endif; endif; szKey = ".apk\\"; szNumName5 = "."; szNumValue5 = "MSApkInstaller"; if (RegDBGetKeyValueEx (szKey, szNumName5, nvType, svNumValue5,nvSize) < 0) then // Set a key name and a value associated with it. if (RegDBSetKeyValueEx (szKey, szNumName5, nType, szNumValue5,nSize) < 0) then MessageBox ("RegDBSetKeyValueEx failed5.", SEVERE); else // Display what RegDBSetKeyValueEx has done. endif; endif; RegDBSetDefaultRoot(HKEY_CURRENT_USER); szProgidKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.apk\\"; szNumName4 = "Progid"; szNumValue4 = "MSApkInstaller"; if (RegDBGetKeyValueEx (szProgidKey, szNumName4, nvType, svNumValue4,nvSize) < 0) then // Set a key name and a value associated with it. if (RegDBSetKeyValueEx (szProgidKey, szNumName4, nType, szNumValue4,nSize) < 0) then MessageBox ("RegDBSetKeyValueEx failed4.", SEVERE); else // Display what RegDBSetKeyValueEx has done. endif; endif; //OpenWithList RegDBSetDefaultRoot(HKEY_CURRENT_USER); szProgidKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.apk\\OpenWithList\\"; szNumName4 = "."; szNumValue4 = "MSApkInstaller"; if (RegDBGetKeyValueEx (szProgidKey, szNumName4, nvType, svNumValue4,nvSize) < 0) then // Set a key name and a value associated with it. if (RegDBSetKeyValueEx (szProgidKey, szNumName4, nType, szNumValue4,nSize) < 0) then MessageBox ("RegDBSetKeyValueEx OpenWithList.", SEVERE); else // Display what RegDBSetKeyValueEx has done. endif; endif; InvalidateRect( 0, NULL,TRUE); end; //删除关联apk,从而删除注册表对应的内容 export prototype ExFn_RegDBDeltKeyValueEx(); function ExFn_RegDBDeltKeyValueEx() STRING szKey,szSubValue; NUMBER nType, nSize, nvType, nvSize; begin // Delete a key to MSApkInstaller. RegDBSetDefaultRoot(HKEY_CLASSES_ROOT); szKey = "MSApkInstaller\\"; if (RegDBDeleteKey (szKey) < 0) then //MessageBox ("RegDBDeleteKey apk failed.", SEVERE); endif; RegDBSetDefaultRoot(HKEY_CURRENT_USER); szKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.apk\\"; if (RegDBDeleteKey (szKey) < 0) then //MessageBox ("RegDBDeleteKey apk failed.", SEVERE); endif; InvalidateRect( 0, NULL,TRUE); end; //注册安装程序 export prototype ExFn_RegDBInstalltKeyValueEx(); function ExFn_RegDBInstalltKeyValueEx() STRING szKey, szNumName, szNumValue, svNumValue,szNumName1, szNumValue1,svNumValue1,szTitle, szMsg; NUMBER nType, nSize, nvType, nvSize; begin //Install key to MS szNumName = ""; szNumValue = TARGETDIR^"\\ms\\MS.exe"; szNumName1 = "Path"; szNumValue1 = TARGETDIR^"\\ms"; nType = REGDB_STRING; nSize = -1; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); szKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\MS.exe"; if (RegDBKeyExist(szKey) == 1) then //MessageBox ("RegDBKeyExis ", SEVERE); else if (RegDBSetKeyValueEx (szKey, szNumName, nType, szNumValue,nSize) < 0) // Set a key name and a value associated with it. then MessageBox ("RegDBSetKeyValueEx ms.exe failed.", SEVERE); endif; endif; if (RegDBKeyExist(szKey) == 1) then //MessageBox ("RegDBKeyExis ", SEVERE); else if (RegDBSetKeyValueEx (szKey, szNumName1, nType, szNumValue1,nSize) < 0) // Set a key name and a value associated with it. then MessageBox ("RegDBSetKeyValueEx path failed.", SEVERE); endif; endif; end; //卸载安装程序 export prototype ExFn_RegDBUnInstalltKeyValueEx(); function ExFn_RegDBUnInstalltKeyValueEx() STRING szKey, szNumName, szNumValue, svNumValue, szTitle, szMsg; NUMBER nType, nSize, nvType, nvSize; begin //Install key to MS szNumName = ""; szNumValue = TARGETDIR^"\\MS.exe"; nType = REGDB_STRING; nSize = -1; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); szKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\MS.exe"; if (RegDBKeyExist(szKey) == 1) then MessageBox("RegDBKeyExist", SEVERE); endif; // Set a key name and a value associated with it. if (RegDBDeleteKey (szKey) < 0) then //MessageBox ("RegDBDeleteKey uninstall failed.", SEVERE); endif; end;出现的错误,请各位指正