Type Library:
A typelib stores information about a COM object: The classid, the interfaces that the object supports, the methods on those interfaces, and so on just about everything you'd find in an IDL file.
The COM system includes a set of COM objects that lets you programmatically walk through the contents of a typelib.
1) Type Library 生成?
1. 在IDL文件中加入library项来描述相应的组件
2. 用MIDL编译得到相应的tlb文件
3. 通过resource script 文件将类型库嵌入组件。 component.rc 1 TYPELIB "component.tlb"
2) Type Library 注册
- LoadTypeLibEx
- RegisterTypeLib
- UnRegisterTypeLib
- QueryPathOfRegTypeLib
3) 通过Type Library来访问组件
#define _WIN32_DCOM
#import "component.dll" no_namespace
#include <iostream.h>
void main()
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
ISumPtr myRef(__uuidof(InsideCOM));
int result = myRef->Sum(5, 13);
cout << "5 + 13 = " << result << endl;
myRef = NULL;
CoUninitialize();
}
COM Component 注册