ITPub博客

首页 > 应用开发 > IT综合 > COM Spec Re-study Memos

COM Spec Re-study Memos

原创 IT综合 作者:j4exgdnter 时间:2009-04-16 22:36:12 0 删除 编辑

看过COM,但是基本上忘记了?看看这个Memo应该会想起来不少东西。

word下载地址

http://j4exgdnter.itpub.net/get/39226/COM%20Spec%20Re.doc

[@more@]

How DLL server exports an interface?

  1. Locates DLL image by lookup registry.
  2. Relies on DLL function export, to export DLL specific DllGetClassObjec, which provides specific IClassFactory Interface.
  3. Through this specific IClassFactory interface, object instance is created over IClassFactory::CreateInstance.
  4. It’s possible for one DLL to hold multiple IClassFactory interfaces (identify by the clsid of DllGetClassObjec function calls).
  5. In upper case, the DLL should appear in multiple ClassId entry of registry.
  6. Multiple calls on DllGetClassObjec will create multiple Objects providing IClassFactory. For an instance, when clients (likely only COM facility) release the object, and reference count becomes zero, it’s automatically deleted.
  7. Certainly, each IClassFactory interface can support multiple objects creation.
  8. IClassFactory::LockServer provides a DLL level reference count. When the reference becomes zero, DLL should be unloaded (but this might have effects on other IClassFactory instances and Object Instances?)
  9. Why named as ClassFactory, a DLL is a Factory that can create Class Instance (objects), though IClassFactory interface, this service can be retrieved.

How exe server exports an interface?

  1. Exe server is loaded by WinExe function called by COM facility.
  2. After that it registers all IClassFactory interfaces it provides. These registrations notify COM facility how/what services this executable provides.
  3. Step4 is interesting, since it’s inter-process communication, it could be timeout, if the executable is running too slow. This is also involves RPC, since the IClassFactory interfaces provided by EXE server are local address, it must be ‘translated’ to client address space. The underlying implementation must rely on client Proxy/ server Stub. That’s, IClassFactory interfaces are actually used by server Stub on behalf of Client Proxy on behalf of Client, while Proxy/Stub communicates via RPC. This detail is not illustrated in the figure below.
  4. Unlike DLL export directly to client, EXE export interfaces to its local stub. Stub & proxy detail is maintained by COM facilities transparently.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21398729/viewspace-1020721/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-04-16

  • 博文量
    39
  • 访问量
    50492