Wednesday, May 25, 2005

ActiveX DLL

I am reading Mastering COM and COM+. Trying the example in chapter 2. Kept getting the dll entry point not found error. Later I found out that I need to add the FirstSrv.def file there to define the dll output.

To summarize the steps:
1. Create the FirstSrv.idl file
2. Create GUID if needed using the guidgen.exe
3. Run midl on the FirstSrv.idl file:
midl FirstSrv.idl
A bunch of files will be generated:
firstsrv_p.c (接口代理文件,包含IDL中所定义的IFirstInterface借口的调动代码)
firstsrv.h (包含C++借口和类型定义,并说明接口ID(IID_IFirstInterface)和CLSID(CLSID_FirstComponent)的符号化常量)
firstsrv_i.c (接口UUID文件,包含头文件中所说明IID,CSLID和LIBID的GUID 定义)
firstsrv.tlb (类型库,是IDL文件的二进制版本)
4. Now, we need to implement IUnknown interface. Create a new Win32 DLL project and add FirstComponent.h
5. Create FirstClassFactory.h
6. Create FirstSrvDll.cpp
7. Last, create FirstSrv.def

Compile and the dll should be there
Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?