windows 如何为所有用户注册一个 COM 对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5665772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Register a COM Object for All Users
提问by user489041
I use regsvr32 MyCOM.dll
to register my com object for my application. This works fine under my admin account. if a switch the user to a non admin, the program fails. It seems that the COM object is not loaded for the non admin user. Any ideas on why this might be or a possible solution?
我用来regsvr32 MyCOM.dll
为我的应用程序注册我的 com 对象。这在我的管理员帐户下工作正常。如果将用户切换为非管理员,程序将失败。似乎没有为非管理员用户加载 COM 对象。关于为什么会这样或可能的解决方案的任何想法?
采纳答案by JSB????
COM objects need to be registeredby an admin user, usually. (There are subtleties and exceptions that I won't get into here, because based on your description that's not what's going on.)
COM 对象通常需要由管理员用户注册。(有些微妙之处和例外我不会在这里讨论,因为根据您的描述,这不是正在发生的事情。)
However, once the COM object has been registered, all users should be able to use it provided that the object was registered with appropriate permissions.
但是,一旦注册了 COM 对象,所有用户都应该能够使用它,前提是该对象以适当的权限注册。
回答by Anders
regsvr32 MyCOM.dll
will call the DllRegisterServer exported function in the dll, what happens there is up to the dll. Usually it will register it's CLSID and other registration info under HKEY_LOCAL_MACHINE\software\Classes (Same as HKEY_CLASSES_ROOT for write operations) and so the registration should be visible to every user unless the user has a conflicting registration under HKEY_CURRENT_USER\software\Classes.
regsvr32 MyCOM.dll
将调用dll中的DllRegisterServer导出函数,会发生什么取决于dll。通常它会在 HKEY_LOCAL_MACHINE\software\Classes 下注册它的 CLSID 和其他注册信息(与写操作的 HKEY_CLASSES_ROOT 相同),因此除非用户在 HKEY_CURRENT_USER\software\Classes 下注册冲突,否则每个用户都应该可以看到注册。
I'm guessing that the registration is not the problem, but that your COM object does something that prevents it from loading for non admin users (Requesting write access to a key under HKEY_LOCAL_MACHINE etc) You can use Process Monitorand look for ACCESS_DENIED errors and see if that provides any clues.
我猜注册不是问题,但是您的 COM 对象做了一些阻止它为非管理员用户加载的事情(请求对 HKEY_LOCAL_MACHINE 下的密钥进行写访问等)您可以使用进程监视器并查找 ACCESS_DENIED 错误和看看这是否提供了任何线索。
The other option is to manually register the object under HKEY_CURRENT_USER\software\Classes for the non-admin user. This should rule out registration issues.
另一个选项是在 HKEY_CURRENT_USER\software\Classes 下为非管理员用户手动注册对象。这应该排除注册问题。