B.4 Visual Basic 6 Runtimes
优质
小牛编辑
124浏览
2023-12-01
把这些代码添加到你的脚本里可以安装或卸载 VB6 runtimes。
正常的版本应该包含下列的文件 (或者修改路径到你使用的另一个路径):
- msvbvm60.dll
- oleaut32.dll
- olepro32.dll
- oleaut32.dll
- comcat.dll
- asycfilt.dll
- stdole2.tlb
一篇 Microsoft 文章解释了如何获取这些文件。
要询问用户必要时是否重启请使用一个带有完成页面的 MUI 或使用 IfRebootFlag 结合 MessageBox 来判断是否需要重启。
!include Library.nsh Var ALREADY_INSTALLED Section "-Install VB6 runtimes" ; 如果程序已经安装,在这里添加设置 $ALREADY_INSTALLED 为非零值的代码。例如: IfFileExists "$INSTDIR\MyApp.exe" 0 new_installation ;将 MyApp.exe 替换为你的应用程序 StrCpy $ALREADY_INSTALLED 1 new_installation: !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "msvbvm60.dll" "$SYSDIR\msvbvm60.dll" "$SYSDIR" !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "oleaut32.dll" "$SYSDIR\oleaut32.dll" "$SYSDIR" !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "olepro32.dll" "$SYSDIR\olepro32.dll" "$SYSDIR" !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "comcat.dll" "$SYSDIR\comcat.dll" "$SYSDIR" !insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_PROTECTED "asycfilt.dll" "$SYSDIR\asycfilt.dll" "$SYSDIR" !insertmacro InstallLib TLB $ALREADY_INSTALLED REBOOT_PROTECTED "stdole2.tlb" "$SYSDIR\stdole2.tlb" "$SYSDIR" SectionEnd Section "-un.Uninstall VB6 runtimes" !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\msvbvm60.dll" !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\oleaut32.dll" !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\olepro32.dll" !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\comcat.dll" !insertmacro UnInstallLib DLL SHARED NOREMOVE "$SYSDIR\asycfilt.dll" !insertmacro UnInstallLib TLB SHARED NOREMOVE "$SYSDIR\stdole2.tlb" SectionEnd
你可以使用类似的代码来安装公共的 VB6 ActiveX 控件 (例如 Windows Common Controls 控件)。