【发布时间】:2012-06-14 22:55:09
【问题描述】:
要注册一个 COM 服务器,我们在提升模式下运行类似的东西:
regsvr32.exe com.dll
要执行每个用户的注册,请在用户帐户中执行:
regsvr32.exe /n /i:user com.dll
regsvr32.exe 支持这些参数:
/u - Unregister server
/i - Call DllInstall passing it an optional [cmdline]; when used with /u calls dll uninstall
/n - do not call DllRegisterServer; this option must be used with /i
/s – Silent; display no message boxes (added with Windows XP and Windows Vista)
在 Delphi 中创建 COM 服务器时,这些方法被导出:
exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer,
DllInstall;
我注意到这些会发生:
- “regsvr32.exe com.dll”调用 DllRegisterServer。
- “regsvr32.exe /u com.dll”调用 DllUnregisterServer。
- “regsvr32.exe /n /i:user com.dll”调用 DllInstall。
- “regsvr32.exe /u /n /i:user com.dll”调用 DllInstall。
我对参数 /n 和 /i 以及 DllUnregisterServer 和 DllInstall 感到困惑。有什么不同吗?
另外,为什么“/u /n /i:user”会调用 Dllinstall?我注意到“HKEY_CURRENT_USER\Software\Classes”中相应的注册表项已被删除。
【问题讨论】:
-
/n 只能 与 /i 一起使用,因此它不是“介于”之间。
-
使用“/n /i”和没有参数(DllRegisterServer)有什么不同吗?什么时候使用“/n /i”,什么时候不使用任何参数?
-
那么“何时使用 DllRegisterServer 而不是(仅)DllInstall”?
-
或者简而言之,什么时候使用DllRegisterServer,什么时候使用DllInstall?有什么不同吗?
-
是的,有区别。 DllRegisterServer() 是最常用的,但 DllInstall() 更灵活,因为您可以向它发送参数。