wuzhuohua

2008年11月12日

Let's go from the bottom up. An interface is simply a group of functions. Those functions are called methods. Interface names start with I, for example IShellLink. In C++, an interface is written as an abstract base class that has only pure virtual functions.

Interfaces may inherit from other interfaces. Inheritance works just like single inheritance in C++. Multiple inheritance is not allowed with interfaces.
Interfaces只能使用單inheritance.

A coclass (short for component object class) is contained in a DLL or EXE, and contains the code behind one or more interfaces. The coclass is said to implement those interfaces. A COM object is an instance of a coclass in memory. Note that a COM "class" is not the same as a C++ "class", although it is often the case that the implementation of a COM class is a C++ class.

coclass 組件對象類。存在于dll或者exe中。coclass可以包跨一個或者多個interfaces。
一個com對象是一個初始后在內存中的實例。

A COM server is a binary (DLL or EXE) that contains on or more coclasses.

A class ID, or CLSID, is a GUID that names a coclass. An interface ID, or IID, is a GUID that names an interface.
guid的兩用

An HRESULT is an integral type used by COM to return error and success codes. It is not a "handle" to anything, despite the H prefix. I'll have more to say about HRESULTs and how to test them later on.

Finally, the COM library is the part of the OS that you interact with when doing COM-related stuff. Often, the COM library is referred to as just "COM," but I will not do that here, to avoid confusion.
com library 是操作系統的一部分
 

The Base Interface - IUnknown

posted @ 2008-11-12 11:37 wuzhuohua 阅读(136) | 评论 (0)编辑 收藏

2008年11月6日

com的服務器端的Iclassfactory的接口是用來產生對象的實例的接口,如果有(也必須有)一個class是由這個接口派生的,如果com對象是進程內組建對象的話,必須實現DllGetClassObject的方法。在client端通過CoCreateInstance,CoCreateInstanceEx,CoGetClassObject三種方法中的一個。把參數clisid,iid和ppv傳給DllGetClassObject方法。由DllGetClassObject創建類廠,并返回類廠對象接口指針。

CoCreateInstance,CoCreateInstanceEx,CoGetClassObject的區別。
CoGetClassObject 這個是最原始也是最基本的方法,他的參數包跨IID_IClassFactory.
CoCreateInstance 比較常用的方法,參數使用IID_IUnknown,從而隱藏了IClassFactory的細節

CoCreateInstanceEx,使用了一個接口數組,因此可以返回多個接口。



 
posted @ 2008-11-06 14:51 wuzhuohua 阅读(946) | 评论 (0)编辑 收藏
仅列出标题  

导航

<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

统计

常用链接

留言簿(1)

随笔档案

友情链接

搜索

最新评论

阅读排行榜

评论排行榜