if (status != S_OK)//建立IclassFactory接口失败自动注册 { hinstLib = LoadLibrary(DllFileName);
// If the handle is valid, try to get the function address. if (hinstLib != NULL) { //HRESULT CA_ServerDllRegisterServer (HINSTANCE server_hInstance); FunctionDLLRegisterServer = (DLLRegisterServer) GetProcAddress(hinstLib, (LPCSTR)"DllRegisterServer"); if (FunctionDLLRegisterServer != NULL) { if (SUCCEEDED(FunctionDLLRegisterServer ())) { status = CoCreateInstance(&GUID_CLSID_RTDXEXINTERFACE,//COM class id NULL,//outer unknown CLSCTX_INPROC_SERVER,//server INFO = 从In-Proc Server 建立COM对象 &IID_IDispatch,//IDispatch id (LPVOID FAR*)&pIDispatch);//pointer to pIDispatch } } FreeLibrary(hinstLib); } } |