gpt4 book ai didi

com - RegSvr 和 RegServer 有什么区别?

转载 作者:行者123 更新时间:2023-12-04 02:11:07 25 4
gpt4 key购买 nike

/RegServer/RegSvr相同或不同,如果不同,为什么/如何?

例如,我已经看到(来自 32 位操作系统的示例)这种风格:

RegSvr32 COM.exe


RegSvr32 COM.dll

或者作为替代方案(在 64 位操作系统上):
COM.exe /RegServer
COM.exe /RegSvr

这些不同的方法是在做同样的事情吗?

最佳答案

COM 服务器在 32 位 64 位操作系统中的注册方式相同。问题与自注册有关,这是注册 COM 服务器的最直接方法 - 通过要求服务器分别更新 HKLM/HKCR 注册表。

由于您无法直接运行 DLL,因此您可以使用帮助程序 regsvr32应用程序。长话短说,它会查看 DLL 是 32 位还是 64 位并使用相应版本的应用程序。然后它加载 DLL 并传递控制以进行注册。

EXE COM 服务器可以直接运行,因此这就是您向它们传递/regserver 或/unregserver 参数所做的工作。

这些方法对 32 位和 64 位 COM 服务器以及 32 位和 64 位操作系统有效。

进一步阅读 - Self-Registration :

If the server is packaged in a DLL module, the DLL must export the functions DllRegisterServer and DllUnregisterServer. Any application that wishes to instruct the server to register itself (that is, all its CLSIDs and type library IDs) can obtain a pointer to DllRegisterServer through the GetProcAddress function. Within DllRegisterServer, the DLL creates all its necessary registry entries, storing the correct path to the DLL for all InprocServer32 or InprocHandler32 entries.

When an application wishes to remove the component from the system, it should unregister that component by calling DllUnregisterServer. Within this call, the server removes exactly those entries it previously created in DllRegisterServer. The server should not blindly remove all entries for its classes because other software may have stored additional entries, such as a TreatAs key.

If the server is packaged in an EXE module, the application wishing to register the server launches the EXE server with the command-line argument /RegServer or -RegServer (case-insensitive). If the application wishes to unregister the server, it launches the EXE with the command-line argument /UnregServer or -UnregServer. The self-registering EXE detects these command-line arguments and invokes the same operations as a DLL would within DllRegisterServerand DllUnregisterServer, respectively, registering its module path under LocalServer32 instead of InprocServer32 or InprocHandler32.

关于com - RegSvr 和 RegServer 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3051823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com