AppendixB.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>DLL/TLB Library Setup</title>
  4. <meta name="viewport" content="width=device-width, initial-scale=1" /><meta name="generator" content="Halibut v1.0 (NSIS Custom Build, SVN:r7318) xhtml-backend" />
  5. <link rel="stylesheet" href="style.css" type='text/css' />
  6. </head>
  7. <body>
  8. <p><a href='AppendixA.html'>Previous</a> | <a href='Contents.html'>Contents</a> | <a href='AppendixC.html'>Next</a></p>
  9. <ul>
  10. <li><a class="btitle" href="AppendixB.html#library"><b>Appendix B: </b>DLL/TLB Library Setup</a></li>
  11. <ul>
  12. <li><a href="AppendixB.html#library_intro">Introduction</a></li>
  13. <li><a href="AppendixB.html#library_install">Library Installation</a></li>
  14. <ul>
  15. <li><a href="AppendixB.html#B.2.1">Introduction</a></li>
  16. <li><a href="AppendixB.html#library_install_parameters">Parameters</a></li>
  17. <li><a href="AppendixB.html#library_install_options">Options</a></li>
  18. <li><a href="AppendixB.html#library_install_notes">Notes</a></li>
  19. <li><a href="AppendixB.html#library_install_examples">Example</a></li>
  20. </ul>
  21. <li><a href="AppendixB.html#library_uninstall">Library Uninstallation</a></li>
  22. <ul>
  23. <li><a href="AppendixB.html#B.3.1">Introduction</a></li>
  24. <li><a href="AppendixB.html#library_uninstall_parameters">Parameters</a></li>
  25. <li><a href="AppendixB.html#library_uninstall_options">Options</a></li>
  26. <li><a href="AppendixB.html#library_uninstall_examples">Example</a></li>
  27. </ul>
  28. <li><a href="AppendixB.html#library_vb6">Visual Basic 6 Run-Time Files</a></li>
  29. </ul>
  30. </ul>
  31. <a name="library"></a><h1>Appendix B: DLL/TLB Library Setup</h1>
  32. <a name="library_intro"></a><h2>B.1 Introduction</h2>
  33. <p>The Library header file can be used to setup dynamic link libraries (DLL) and type libraries (TLB). If necessary, the following actions will be performed:</p>
  34. <ul>
  35. <li>File copying</li><li>File copying on reboot</li><li>Version checks</li><li>Registration and unregistration</li><li>Registration and unregistration on reboot</li><li>Shared DLL counting</li><li>Windows File Protection checks</li></ul>
  36. <p>The macros are stored in the header file Library.nsh, which should be included in scripts using this system:</p>
  37. <pre>!include Library.nsh
  38. </pre>
  39. <p>Note that the library macros are limited on non-Windows platforms. DLL version information is required when compiling on non-Windows platforms.</p>
  40. <a name="library_install"></a><h2>B.2 Library Installation</h2>
  41. <a name="B.2.1"></a><h3>B.2.1 Introduction</h3>
  42. <p>The InstallLib macro allows you to install a library. It sets the error flag if something went wrong during library setup.</p>
  43. <p>To ask the user for a reboot, if required, use the Modern UI with a Finish page or use <a href="Chapter4.html#ifrebootflag">IfRebootFlag</a> and make your own page or message box.</p>
  44. <a name="library_install_parameters"></a><h3>B.2.2 Parameters</h3>
  45. <pre>libtype shared install localfile destfile tempbasedir
  46. </pre>
  47. <p><b>libtype</b></p>
  48. <p>The type of the library</p>
  49. <p>DLL - Dynamic link library (DLL)<br> REGDLL - DLL that has to be registered<br> REGEXE - EXE COM server that has to be registered using /regserver<br> TLB - Type library or DLL that contains a type library<br> REGDLLTLB - DLL that has to be registered and contains a type library<br></p>
  50. <p><b>shared</b></p>
  51. <p>Specify whether the library is shared with other applications</p>
  52. <p>NOTSHARED - The library is not shared<br> $VARNAME - Variable that is empty when the application is installed for the first time, which is when the shared library count will be increased.<br></p>
  53. <p><b>install</b></p>
  54. <p>Specify the installation method</p>
  55. <p>REBOOT_PROTECTED</p>
  56. <ul>
  57. <li>Upgrade the library on reboot when in use (required for system files).</li><li>Upgrade the library if the file is not protected by Windows File Protection.</li></ul>
  58. <p>NOREBOOT_PROTECTED</p>
  59. <ul>
  60. <li>Warns the user when the library is in use. The user will have to close applications using the library.</li><li>Upgrade the library if the file is not protected by Windows File Protection.</li></ul>
  61. <p>REBOOT_NOTPROTECTED</p>
  62. <ul>
  63. <li>Upgrade the library on reboot when in use (required for system files).</li><li>Upgrade the library without checking for Windows File Protection.</li></ul>
  64. <p>NOREBOOT_NOTPROTECTED</p>
  65. <ul>
  66. <li>Warns the user when the library is in use. The user will have to close applications using the library.</li><li>Upgrade the library without checking for Windows File Protection.</li></ul>
  67. <p><b>localfile</b></p>
  68. <p>Location of the library on the compiler system</p>
  69. <p><b>destfile</b></p>
  70. <p>Location to store the library on the user's system</p>
  71. <p><b>tempbasedir</b></p>
  72. <p>Directory on the user's system to store a temporary file when the system has to be rebooted.</p>
  73. <p>For Windows 9x/ME support, this directory should be on the same volume as the destination file (destfile). The Windows temp directory could be located on any volume, so you cannot use this directory.</p>
  74. <a name="library_install_options"></a><h3>B.2.3 Options</h3>
  75. <p><a href="Chapter5.html#define">Define</a> any of the following before inserting a InstallLib macro to modify its behavior as specified.</p>
  76. <a name="B.2.3.1"></a><h4>B.2.3.1 LIBRARY_X64</h4>
  77. <ul>
  78. <li>Installs a DLL built for Windows x64.</li><li><strong>Warning:</strong> This resets <a href="Chapter4.html#setregview">SetRegView</a> and file system redirection.</li></ul>
  79. <a name="B.2.3.2"></a><h4>B.2.3.2 LIBRARY_SHELL_EXTENSION</h4>
  80. <ul>
  81. <li>Define this before inserting InstallLib macro to call SHChangeNotify with SHCNE_ASSOCCHANGED after registration.</li><li>Use this to refresh the shell when installing a shell extension or when changing file associations.</li></ul>
  82. <a name="B.2.3.3"></a><h4>B.2.3.3 LIBRARY_COM</h4>
  83. <ul>
  84. <li>Define this before inserting InstallLib macro to call CoFreeUnusedLibraries after registration.</li><li>Use this for unloading all unnecessary libraries from memory when installing COM libraries.</li></ul>
  85. <a name="B.2.3.4"></a><h4>B.2.3.4 LIBRARY_IGNORE_VERSION</h4>
  86. <ul>
  87. <li>Define this before inserting InstallLib macro to ignore version information in the file and always install it, even if it already exists.</li><li>Use this when an older or specific version is required.</li><li>Not recommended for DLLs installed to $SYSDIR.</li></ul>
  88. <a name="B.2.3.5"></a><h4>B.2.3.5 LIBRARY_INSTALL_EQUAL_VERSION</h4>
  89. <ul>
  90. <li>Define this before inserting InstallLib macro to overwrite the file even if the version is the same as the existing file.</li></ul>
  91. <a name="library_install_notes"></a><h3>B.2.4 Notes</h3>
  92. <ul>
  93. <li>If you need to support Windows 9x/ME, you can only use short filenames (8.3).</li><li><strong>Warning:</strong> Always use redistributable files when deploying DLLs, never copy files from your system directory!</li></ul>
  94. <a name="library_install_examples"></a><h3>B.2.5 Example</h3>
  95. <a name="B.2.5.1"></a><h4>B.2.5.1 Unshared DLL</h4>
  96. <pre> !insertmacro InstallLib REGDLL NOTSHARED REBOOT_NOTPROTECTED dllname.dll $SYSDIR\dllname.dll $SYSDIR
  97. </pre>
  98. <a name="B.2.5.2"></a><h4>B.2.5.2 Shared DLL</h4>
  99. <pre> ;Add code here that sets $ALREADY_INSTALLED to a non-zero value if the application is
  100. ;already installed. For example:
  101. IfFileExists &quot;$INSTDIR\MyApp.exe&quot; 0 new_installation ;Replace MyApp.exe with your application filename
  102. StrCpy $ALREADY_INSTALLED 1
  103. new_installation:
  104. !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED dllname.dll $SYSDIR\dllname.dll $SYSDIR
  105. </pre>
  106. <a name="library_uninstall"></a><h2>B.3 Library Uninstallation</h2>
  107. <a name="B.3.1"></a><h3>B.3.1 Introduction</h3>
  108. <p>The UnInstallLib macro allows you to uninstall a library. It sets the error flag if something went wrong during library removal.</p>
  109. <a name="library_uninstall_parameters"></a><h3>B.3.2 Parameters</h3>
  110. <pre>libtype shared uninstall file
  111. </pre>
  112. <p><b>libtype</b></p>
  113. <p>The type of the library</p>
  114. <p>DLL - Dynamic link library (DLL)<br> REGDLL - DLL that has to be unregistered<br> REGEXE - EXE COM server that has to be unregistered using /unregserver<br> TLB - Type library or DLL that contains a type library<br> REGDLLTLB - DLL that has to be unregistered and contains a type library<br></p>
  115. <p><b>shared</b></p>
  116. <p>Specify whether the library is shared with other applications</p>
  117. <p>NOTSHARED - The library is not shared<br> SHARED - The library is shared and should be removed if the shared library count indicates that the file is not in use anymore..<br></p>
  118. <p><b>uninstall</b></p>
  119. <p>Specify the uninstallation method</p>
  120. <p>NOREMOVE</p>
  121. <ul>
  122. <li>The library should not be removed. You should use this option for common or important system files such as the Visual Basic/C++/MFC runtimes.</li></ul>
  123. <p>REBOOT_PROTECTED</p>
  124. <ul>
  125. <li>Remove the library on reboot when in use (required for system files).</li><li>Remove the library if the file is not protected by Windows File Protection.</li></ul>
  126. <p>NOREBOOT_PROTECTED</p>
  127. <ul>
  128. <li>Warns the user when the library is in use. The user will have to close applications using the library.</li><li>Remove the library if the file is not protected by Windows File Protection.</li></ul>
  129. <p>REBOOT_NOTPROTECTED</p>
  130. <ul>
  131. <li>Remove the library on reboot when in use (required for system files).</li><li>Remove the library without checking for Windows File Protection.</li></ul>
  132. <p>NOREBOOT_NOTPROTECTED</p>
  133. <ul>
  134. <li>Warns the user when the library is in use. The user will have to close applications using the library.</li><li>Remove the library without checking for Windows File Protection.</li></ul>
  135. <p><b>file</b></p>
  136. <p>Location of the library</p>
  137. <a name="library_uninstall_options"></a><h3>B.3.3 Options</h3>
  138. <p><a href="Chapter5.html#define">Define</a> any of the following before inserting a UnInstallLib macro to modify its behavior as specified.</p>
  139. <a name="B.3.3.1"></a><h4>B.3.3.1 LIBRARY_X64</h4>
  140. <ul>
  141. <li>Uninstalls a DLL built for Windows x64.</li><li><strong>Warning:</strong> This resets <a href="Chapter4.html#setregview">SetRegView</a> and file system redirection.</li></ul>
  142. <a name="B.3.3.2"></a><h4>B.3.3.2 LIBRARY_SHELL_EXTENSION</h4>
  143. <ul>
  144. <li>Define this before inserting UninstallLib macro to call SHChangeNotify with SHCNE_ASSOCCHANGED after unregistration. Use this to refresh the shell when uninstalling a shell extension or when changing file associations.</li></ul>
  145. <a name="B.3.3.3"></a><h4>B.3.3.3 LIBRARY_COM</h4>
  146. <ul>
  147. <li>Define this before inserting UninstallLib macro to call CoFreeUnusedLibraries after unregistration. Use this for unloading all unnecessary libraries from memory when uninstalling COM libraries.</li></ul>
  148. <a name="library_uninstall_examples"></a><h3>B.3.4 Example</h3>
  149. <pre> !insertmacro UnInstallLib REGDLL SHARED REBOOT_NOTPROTECTED $SYSDIR\dllname.dll
  150. </pre>
  151. <a name="library_vb6"></a><h2>B.4 Visual Basic 6 Run-Time Files</h2>
  152. <p>A new VB6RunTime.nsh header file is available for the setup of the VB6 run-time files. To obtain the latest run-time files, download <a href="https://nsis.sourceforge.io/vb6runtime.zip">vb6runtime.zip</a> and extract this file.</p>
  153. <pre> !include VB6RunTime.nsh
  154. Var AlreadyInstalled
  155. Section &quot;-Install VB6 run-time files&quot;
  156. ;Add code here that sets $AlreadyInstalled to a non-zero value if the application is already installed. For example:
  157. IfFileExists &quot;$INSTDIR\MyApp.exe&quot; 0 new_installation ;Replace MyApp.exe with your application filename
  158. StrCpy $AlreadyInstalled 1
  159. new_installation:
  160. !insertmacro VB6RunTimeInstall C:\vb6runtimes $AlreadyInstalled ;Replace C:\vb6runtimes with the location of the files
  161. SectionEnd
  162. Section &quot;-un.Uninstall VB6 run-time files&quot;
  163. !insertmacro VB6RunTimeUnInstall
  164. SectionEnd
  165. </pre>
  166. <p>Remarks:</p>
  167. <ul>
  168. <li>You may have to install additional files for such Visual Basic application to work, such as OCX files for user interface controls.</li><li>Installation of the run-time files requires Administrator or Power User privileges. Use the Multi-User header file to verify whether these privileges are available.</li><li>Add a Modern UI finish page or another check (see <a href="Chapter4.html#ifrebootflag">IfRebootFlag</a>) to allow the user to restart the computer when necessary.</li></ul>
  169. <p><a href='AppendixA.html'>Previous</a> | <a href='Contents.html'>Contents</a> | <a href='AppendixC.html'>Next</a></p>
  170. </body></html>