修改opc服务端,将opc服务改为启动即注册

This commit is contained in:
shi_jq 2025-02-26 19:27:13 +08:00
parent 2e1b3bc130
commit 0227348b17

View File

@ -152,14 +152,9 @@ bool LightOpcOpt::regServer(std::string name,int appId)
} }
appname = name; appname = name;
m_appId = appId; m_appId = appId;
char np[FILENAME_MAX + 32];
GetModuleFileName(NULL, np + 1, sizeof(np) - 8);
np[0] = '"'; strcat(np, "\"");
LOGINFO("reg fileName:%s", np);
if (loServerRegister(&CLSID_LightOPCServer[appId-1], if (loServerRegister(&CLSID_LightOPCServer[appId-1],
appname.c_str(), appname.c_str(), np, 0)) appname.c_str(), appname.c_str(), NULL, 0))
{ {
LOGERROR("loServerRegister failed!"); LOGERROR("loServerRegister failed!");
return false; return false;
@ -173,15 +168,15 @@ bool LightOpcOpt::regServer(std::string name,int appId)
bool LightOpcOpt::closeRegServer() bool LightOpcOpt::closeRegServer()
{ {
if (loServerUnregister(&CLSID_LightOPCServer[m_appId-1], appname.c_str())) // if (loServerUnregister(&CLSID_LightOPCServer[m_appId-1], appname.c_str()))
{ // {
LOGERROR("loServerUnregister failed!"); // LOGERROR("loServerUnregister failed!");
return false; // return false;
} // }
else // else
{ // {
LOGINFO("loServerUnregister successed!"); // LOGINFO("loServerUnregister successed!");
} // }
return true; return true;
} }
@ -568,7 +563,7 @@ STDMETHODIMP myClassFactory::QueryInterface(REFIID iid, LPVOID *ppInterface)
AddRef(); AddRef();
return S_OK; return S_OK;
} }
LOGERROR("myClassFactory::QueryInterface() Failed"); LOGINFO("myClassFactory::QueryInterface() Failed");
*ppInterface = NULL; *ppInterface = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }