AppendixB.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns='http://www.w3.org/1999/xhtml'>
  4. <head>
  5. <title>DLL/TLB Library Setup</title>
  6. <meta name="generator" content="Halibut v1.0 (NSIS Custom Build, SVN:r?) xhtml-backend" />
  7. <link rel="stylesheet" href="style.css" type='text/css' />
  8. </head>
  9. <body>
  10. <p><a href='AppendixA.html'>Previous</a> | <a href='Contents.html'>Contents</a> | <a href='AppendixC.html'>Next</a></p>
  11. <ul>
  12. <li><a class="btitle" href="AppendixB.html#library"><b>Appendix B: </b>DLL/TLB Library Setup</a></li>
  13. <ul>
  14. <li><a href="AppendixB.html#library_intro">Introduction</a></li>
  15. <li><a href="AppendixB.html#library_install">Library Installation</a></li>
  16. <ul>
  17. <li><a href="AppendixB.html#B.2.1">Introduction</a></li>
  18. <li><a href="AppendixB.html#library_install_parameters">Parameters</a></li>
  19. <li><a href="AppendixB.html#library_install_options">Options</a></li>
  20. <li><a href="AppendixB.html#library_install_notes">Notes</a></li>
  21. <li><a href="AppendixB.html#library_install_examples">Example</a></li>
  22. </ul>
  23. <li><a href="AppendixB.html#library_uninstall">Library Uninstallation</a></li>
  24. <ul>
  25. <li><a href="AppendixB.html#B.3.1">Introduction</a></li>
  26. <li><a href="AppendixB.html#library_uninstall_parameters">Parameters</a></li>
  27. <li><a href="AppendixB.html#library_uninstall_options">Options</a></li>
  28. <li><a href="AppendixB.html#library_uninstall_examples">Example</a></li>
  29. </ul>
  30. <li><a href="AppendixB.html#library_vb6">Visual Basic 6 Run-Time Files</a></li>
  31. </ul>
  32. </ul>
  33. <a name="library"></a><h1>Appendix B: DLL/TLB Library Setup</h1>
  34. <a name="library_intro"></a><h2>B.1 Introduction</h2>
  35. <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>
  36. <ul>
  37. <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>
  38. <p>The macros are stored in the header file Library.nsh, which should be included in scripts using this system:</p>
  39. <pre>!include Library.nsh
  40. </pre>
  41. <p>Note that the library macros are limited on non-Windows platforms. DLL version information is required when compiling on non-Windows platforms.</p>
  42. <a name="library_install"></a><h2>B.2 Library Installation</h2>
  43. <a name="B.2.1"></a><h3>B.2.1 Introduction</h3>
  44. <p>The InstallLib macro allows you to install a library. It sets the error flag if something went wrong during library setup.</p>
  45. <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>
  46. <a name="library_install_parameters"></a><h3>B.2.2 Parameters</h3>
  47. <pre>libtype shared install localfile destfile tempbasedir
  48. </pre>
  49. <p><b>libtype</b></p>
  50. <p>The type of the library</p>
  51. <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>
  52. <p><b>shared</b></p>
  53. <p>Specify whether the library is shared with other applications</p>
  54. <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>
  55. <p><b>install</b></p>
  56. <p>Specify the installation method</p>
  57. <p>REBOOT_PROTECTED</p>
  58. <ul>
  59. <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>
  60. <p>NOREBOOT_PROTECTED</p>
  61. <ul>
  62. <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>
  63. <p>REBOOT_NOTPROTECTED</p>
  64. <ul>
  65. <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>
  66. <p>NOREBOOT_NOTPROTECTED</p>
  67. <ul>
  68. <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>
  69. <p><b>localfile</b></p>
  70. <p>Location of the library on the compiler system</p>
  71. <p><b>destfile</b></p>
  72. <p>Location to store the library on the user's system</p>
  73. <p><b>tempbasedir</b></p>
  74. <p>Directory on the user's system to store a temporary file when the system has to be rebooted.</p>
  75. <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>
  76. <a name="library_install_options"></a><h3>B.2.3 Options</h3>
  77. <p><a href="Chapter5.html#define">Define</a> any of the following before inserting a InstallLib macro to modify its behavior as specified.</p>
  78. <a name="B.2.3.1"></a><h4>B.2.3.1 LIBRARY_X64</h4>
  79. <ul>
  80. <li>Installs a DLL built for Windows x64.</li><li><b>Warning:</b> This resets file system redirection.</li></ul>
  81. <a name="B.2.3.2"></a><h4>B.2.3.2 LIBRARY_SHELL_EXTENSION</h4>
  82. <ul>
  83. <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>
  84. <a name="B.2.3.3"></a><h4>B.2.3.3 LIBRARY_COM</h4>
  85. <ul>
  86. <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>
  87. <a name="B.2.3.4"></a><h4>B.2.3.4 LIBRARY_IGNORE_VERSION</h4>
  88. <ul>
  89. <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>
  90. <a name="library_install_notes"></a><h3>B.2.4 Notes</h3>
  91. <ul>
  92. <li>If you need to support Windows 9x/ME, you can only use short filenames (8.3).</li><li><b>Warning:</b> Always use redistributable files when deploying DLLs, never copy files from your system directory!</li></ul>
  93. <a name="library_install_examples"></a><h3>B.2.5 Example</h3>
  94. <a name="B.2.5.1"></a><h4>B.2.5.1 Unshared DLL</h4>
  95. <pre> !insertmacro InstallLib REGDLL NOTSHARED REBOOT_NOTPROTECTED dllname.dll $SYSDIR\dllname.dll $SYSDIR
  96. </pre>
  97. <a name="B.2.5.2"></a><h4>B.2.5.2 Shared DLL</h4>
  98. <pre> ;Add code here that sets $ALREADY_INSTALLED to a non-zero value if the application is
  99. ;already installed. For example:
  100. IfFileExists &quot;$INSTDIR\MyApp.exe&quot; 0 new_installation ;Replace MyApp.exe with your application filename
  101. StrCpy $ALREADY_INSTALLED 1
  102. new_installation:
  103. !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED dllname.dll $SYSDIR\dllname.dll $SYSDIR
  104. </pre>
  105. <a name="library_uninstall"></a><h2>B.3 Library Uninstallation</h2>
  106. <a name="B.3.1"></a><h3>B.3.1 Introduction</h3>
  107. <p>The UnInstallLib macro allows you to uninstall a library. It sets the error flag if something went wrong during library removal.</p>
  108. <a name="library_uninstall_parameters"></a><h3>B.3.2 Parameters</h3>
  109. <pre>libtype shared uninstall file
  110. </pre>
  111. <p><b>libtype</b></p>
  112. <p>The type of the library</p>
  113. <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>
  114. <p><b>shared</b></p>
  115. <p>Specify whether the library is shared with other applications</p>
  116. <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>
  117. <p><b>uninstall</b></p>
  118. <p>Specify the uninstallation method</p>
  119. <p>NOREMOVE</p>
  120. <ul>
  121. <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>
  122. <p>REBOOT_PROTECTED</p>
  123. <ul>
  124. <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>
  125. <p>NOREBOOT_PROTECTED</p>
  126. <ul>
  127. <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>
  128. <p>REBOOT_NOTPROTECTED</p>
  129. <ul>
  130. <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>
  131. <p>NOREBOOT_NOTPROTECTED</p>
  132. <ul>
  133. <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>
  134. <p><b>file</b></p>
  135. <p>Location of the library</p>
  136. <a name="library_uninstall_options"></a><h3>B.3.3 Options</h3>
  137. <p><a href="Chapter5.html#define">Define</a> any of the following before inserting a UnInstallLib macro to modify its behavior as specified.</p>
  138. <a name="B.3.3.1"></a><h4>B.3.3.1 LIBRARY_X64</h4>
  139. <ul>
  140. <li>Uninstalls a DLL built for Windows x64.</li><li><b>Warning:</b> This resets <a href="Chapter4.html#setregview">SetRegView</a> and file system redirection.</li></ul>
  141. <a name="B.3.3.2"></a><h4>B.3.3.2 LIBRARY_SHELL_EXTENSION</h4>
  142. <ul>
  143. <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>
  144. <a name="B.3.3.3"></a><h4>B.3.3.3 LIBRARY_COM</h4>
  145. <ul>
  146. <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>
  147. <a name="library_uninstall_examples"></a><h3>B.3.4 Example</h3>
  148. <pre> !insertmacro UnInstallLib REGDLL SHARED REBOOT_NOTPROTECTED $SYSDIR\dllname.dll
  149. </pre>
  150. <a name="library_vb6"></a><h2>B.4 Visual Basic 6 Run-Time Files</h2>
  151. <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="http://nsis.sourceforge.net/vb6runtime.zip">vb6runtime.zip</a> and extract this file.</p>
  152. <pre> !include VB6RunTime.nsh
  153. Var AlreadyInstalled
  154. Section &quot;-Install VB6 run-time files&quot;
  155. ;Add code here that sets $AlreadyInstalled to a non-zero value if the application is already installed. For example:
  156. IfFileExists &quot;$INSTDIR\MyApp.exe&quot; 0 new_installation ;Replace MyApp.exe with your application filename
  157. StrCpy $AlreadyInstalled 1
  158. new_installation:
  159. !insertmacro VB6RunTimeInstall C:\vb6runtimes $AlreadyInstalled ;Replace C:\vb6runtimes with the location of the files
  160. SectionEnd
  161. Section &quot;-un.Uninstall VB6 run-time files&quot;
  162. !insertmacro VB6RunTimeUnInstall
  163. SectionEnd
  164. </pre>
  165. <p>Remarks:</p>
  166. <ul>
  167. <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>
  168. <p><a href='AppendixA.html'>Previous</a> | <a href='Contents.html'>Contents</a> | <a href='AppendixC.html'>Next</a></p>
  169. <hr />
  170. <address>
  171. </address>
  172. </body>
  173. </html>