VC编写的OPC 服务器编译连接后,用Kepware的客户端测试程序连接时报错!
错误:CoCreateInstance:没有注册类别
请教各位大侠:用进程内COM组件创建OPC服务器时,是不是要先初始化COM库和创建COM对象?部分代码如下:
//动态链接库主函数
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
InitDeviceBuffer();
hInstance = (HMODULE)hModule;
InitParm();
InitOPCServer(hInstance, &OPCServerInfo ,
&OPCRegInfo, &VendorInfo,ReadVariant,WriteVariant);
break;
}
case DLL_THREAD_ATTACH://DLL在加载过程中要CALL多次,添加Tag操作只需一次
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
/////进程内组件标准函数
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
{
HRESULT hr;
hr = DLL_GetClassObject(rclsid, riid, ppvOut);
if(SUCCEEDED(hr))
{
if(!bCalled)
{
LoadDeviceTag();
bCalled = true;
}
}
return hr;
}
STDAPI DllCanUnloadNow(void)
{
return DLL_CanUnloadNow();
}
STDAPI DllRegisterServer(void)
{
return DLL_RegisterServer();
}
STDAPI DllUnregisterServer(void)
{
return DLL_UnregisterServer();
}