天天看点

进程内组件注册位置错误可能导致"没有注册类别"的错误

 对于进程内的COM服务来说,如果将组件注册到这个位置(InProcServer):

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID

   {CLSID}

      InprocServer

         (Default) = FullPathFile.DLL

在WIN32系统中,调用CoGetClassObject(...)或CoCreateInstance(...)函数可能会返回"没有注册类别"错误,这是因为"The 32-bit and 64-bit in-process servers should use the InprocServer32 entry".所以WIN32中,应使用InProcServer32而不是InProcServer.

不过,如果你的组件是本地服务,你可以注册到:

      LocalServer

         (Default) = FullPathFile.EXE

即使在WIN32系统中,也是可以的.原因如下:

"If you are implementing classes as services, you should be aware that the LocalService named value is used in preference to the LocalServer32 key for local and remote activation requests—if LocalService exists and refers to a valid service, the LocalServer32 key is ignored."

详情参考msdn.

本文转自jetyi51CTO博客,原文链接:http://blog.51cto.com/jetyi/671552 ,如需转载请自行联系原作者

继续阅读