INSTALLSHIELD use miscellaneous

xiaoxiao2021-03-06  55

Today, I made a installer with InstallShield. I used to have some installations in INSTALLSHIELD before work, but there is nothing to study, the feeling is still quite stronger. Today, due to some special issues, INSTALLSHIELD is required to implement Script implementation. Summarize the following usage:

1. Add checkbox selection window #define svautologon "Set the system to automatically log in" #define svshell "to modify the system shell to close the screen protection for this program, modify the power management mode" #define svmedia "installation Universal Media Support Pack "#define smCustom" CustomMedia "smMedia = MEDIA; MEDIA = smCustom; ComponentAddItem (MEDIA, svAutoLogon, 0, TRUE); ComponentAddItem (MEDIA, svShell, 0, FALSE); ComponentAddItem (MEDIA, svMedia, 0, TRUE); ComponentAddItem ( Media, svscreesave, 0, true); NRESULT = SDASKOPTIONS ("You can also do the following settings after the system installation:", "Please select:", ",", ", nonexclusive); Media = smmedia You can use NResult = ComponentisItemSelected (SMCUSTOM, SVAUTOLOGON);

During use, I found that SDASKOptions only support 4 options by default, but in the help, I can expand by custom window resources, I tried it, there is no success, and there is no in-depth study. At least for me, four options have been enough. Oh, I am still so lazy!

2. Access the registry

The access registry can be in two ways, the easiest, of course, is directly connected to the Register Sets on the Resources page, and it is intuitive and convenient, and it is also possible to set whether to uninstall when it is reversed. Another method is by Script, the advantage of flexible, relatively easy nRootKey = HKEY_LOCAL_MACHINE; if (RegDBSetDefaultRoot (nRootKey) = 0) then // set a custom login RegDBSetKeyValueEx ( "SOFTWARE // Microsoft // Windows NT // CurrentVersion / / Winlogon "," DefaultUserName ", REGDB_STRING, GUSER, -1); RegDBSetKeyValueEx (" SOFTWARE // Microsoft // Windows NT // CurrentVersion // Winlogon "," AutoAdminLogon ", REGDB_STRING," 1 ", - 1); RegDBSetKeyValueEx ("Software // Microsoft // Windows NT // CurrentVersion // WinLogon", "DefaultPassword", Regdb_String, GPWD, -1); ENDIF; the above code implements a function of adding information to the registry. 3. Set environment variables

Since INSTALLSHIELD does not provide a function of directly modifying environment variables, we can only achieve the purpose by modifying the registry key: nrootkey = hkey_local_machine; if (regdbsetdefault (nRootKey) = 0) THEN // Add system path regdbgetKeyValueex ("system // controlset001 // control // session manager // environment "," Path ", nvtype, szpath, nvsize); if szpath! =" "THEN PATHSET (SZPATH); PathDelete (" ADPLAY ", Partial; Pathadd (Targetdir " //////// adPlay "," ", PARTIAL, BEFORE); PathGet (szPath); MessageBox (szPath, INFORMATION); else szPath = TARGETDIR " // adPlay "; endif; RegDBSetKeyValueEx (" SYSTEM // ControlSet001 // Control // Session Manager / / Environment "," path ", regdb_string, szpath, -1); endif;

4. Let the registry value are not installed

The above code seems to have no problem, but unfortunately, when I executed a counter-installation, the tragedy happened, all the settings in my PATH path were deleted. It turns out that INSTALLSHIELD will reverse his own registration value added to the registry to the registry. But now we don't need this feature. According to my experience, since the Register Sets on the Resources page can modify whether it is reversed, then this feature should be implemented through the code. So press F1, open your help, find it out, but you can't find a function that is not reversed. Then search it again, still didn't find it. Under the trouble, I had to help again. After reading it, I finally found that there is the following paragraph in the help of RegdbsetKeyValueex: when Yy is createex. While Logging is enabled.

When they are created automatically by InstallShield during the installation process. When they are created as a result of calling one of the special registry-related functions. While logging is enabled. Does that mean that as long as the Logging ban off can fulfill my requirements The function is. Unfortunately, there is no explanation that DISABLE dropped Logging. After some exploration, I finally found disable (logging); I can disable the automatic installation record, and quickly add disable (logging) before the code; and enable (logging); Sure enough, never put it when it is installed The registration item deletes. Of course, if we need it, you can add the code to modify the registry key when you are reversed.

转载请注明原文地址:https://www.9cbs.com/read-118199.html

New Post(0)