Add frequently used Inno Setup code to favorites]

Source: Internet
Author: User
1. Execute (expandconstant ('{cmd}'), '/C dir c: \> a.txt ', expandconstant ('{app}'), sw_shownormal, ewnowait, resultcode );

 

2. Some specific installation interfaces [Code] function shouldskippage (pageid: integer): Boolean; beginif pageid = wpready thenresult: = true; end; wpready is the Pascal script in the Inno help query on the preparation and installation page pageid: The curpageid value wpwelcome, wplicense, wppassword, signature, wpuserinfo, wpselectdir, wpselectcomponents, expires, expires, if wpready, wppreparing, wpinstalling, wpinfoafter, and wpfinished are custom forms, pageid may be 100. In the curpagechanged (curpageid: integer) method, the actual number of curpageids is printed.

 

3. Obtain the installation path vardbpath: string; RTN: Boolean; RTN: = regquerystringvalue (HKEY_LOCAL_MACHINE, 'Software \ Microsoft \ MSSQLServer \ setup', 'sqlpath', dbpath) of sqlserver ); if (! RTN) Then dbpath: = expandconstant ('{app }');

 

4. Obtain the IP address of the Local Machine: string; RTN: Boolean; // {083565f8-18f0-4f92-8797-9ad701fcf1bf}. For details, see RTN at LOCAL_MACHINE \ Software \ Microsoft \ Windows NT \ CurrentVersion \ networkcards: = regquerystringvalue (HKEY_LOCAL_MACHINE, 'System \ CurrentControlSet \ Services \ {parameters} \ Parameters \ tcpip', 'ipaddress', ip); If (not RTN) or (IP = '0. 0.0.0 ') or (IP = '') Then IP: = '2017. 0.0.1 ';

 

5. Check whether the database is installed // check whether sqltrycreateoleobject ('sqldmo. sqlserver '); exceptraiseexception (' You have not installed the SQL database. '#13 # 13' (error ''' + getexceptionmessage + ''' occurred)'); end;

 

6. Select a component based on environment variables. For details about how to obtain the system environment variable value, see Method 6 Procedure curpagechanged (curpageid: integer); varpath: string; RTN: Boolean; begin // msgbox (inttostr (curpageid), mbinformation, mb_ OK); If (curpageid = 7) thenbeginrtn: = checktomcat6 (PATH ); if RTN then // If Tomcat is not installed before, select the component. Otherwise, beginwizardform is not selected. componentslist. checkitem (2, councheck); wizardform. componentslist. itemenabled [2]: = false; end;

 

7. system environment variable operation read: function getenv (const envvar: string): string; example: getenv ('java _ home') settings: [setup] changesenvironment = true [Code] // environment variable name, value, whether to install (delete), whether all users have valid procedure setenv (aenvname, aenvvalue: string; aisinstall: boolean); // sets the Environment Variable Function varsorgvalue: string; X, Len: integer; begin // obtain the previous value regquerystringvalue (HKEY_LOCAL_MACHINE, 'System \ CurrentControlSet \ Control \ Session Manager \ environment ', aenvname, sorgvalue) sorgvalue: = trim (sorgvalue); begruntime: = pos (uppercase (aenvvalue ), uppercase (sorgvalue); Len: = length (aenvvalue); If aisinstall then // whether to install or reverse install beginif length (sorgvalue)> 0 then aenvvalue: = '; '+ aenvvalue; if x = 0 Then insert (aenvvalue, sorgvalue, length (sorgvalue) + 1); endelsebeginif x> 0 Then delete (sorgvalue, X, Len ); if length (sorgvalue) = 0 thenbeginregdeletevalue (HKEY_LOCAL_MACHINE, 'System \ CurrentControlSet \ Control \ Session Manager \ environment ', aenvname); exit; end; stringchange (sorgvalue ,';; ','; '); regwritestringvalue (HKEY_LOCAL_MACHINE, 'System \ CurrentControlSet \ Control \ Session Manager \ environment', aenvname, sorgvalue) end;

 

8. Obtain the NT service installation path. After the Windows service is installed on the system, a directory is created with the servicename of the service under "HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \" in the registry, the directory contains "ImagePath" to obtain the installation path of Tomcat 6: regquerystringvalue (HKEY_LOCAL_MACHINE, 'System \ CurrentControlSet \ Services \ tomcat6 ', 'ImagePath', Spath );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.