修改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;
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],
appname.c_str(), appname.c_str(), np, 0))
appname.c_str(), appname.c_str(), NULL, 0))
{
LOGERROR("loServerRegister failed!");
return false;
@ -173,15 +168,15 @@ bool LightOpcOpt::regServer(std::string name,int appId)
bool LightOpcOpt::closeRegServer()
{
if (loServerUnregister(&CLSID_LightOPCServer[m_appId-1], appname.c_str()))
{
LOGERROR("loServerUnregister failed!");
return false;
}
else
{
LOGINFO("loServerUnregister successed!");
}
// if (loServerUnregister(&CLSID_LightOPCServer[m_appId-1], appname.c_str()))
// {
// LOGERROR("loServerUnregister failed!");
// return false;
// }
// else
// {
// LOGINFO("loServerUnregister successed!");
// }
return true;
}
@ -568,7 +563,7 @@ STDMETHODIMP myClassFactory::QueryInterface(REFIID iid, LPVOID *ppInterface)
AddRef();
return S_OK;
}
LOGERROR("myClassFactory::QueryInterface() Failed");
LOGINFO("myClassFactory::QueryInterface() Failed");
*ppInterface = NULL;
return E_NOINTERFACE;
}