静默安装控件

QString modulePathName = QCoreApplication::applicationDirPath() + "\\控件名称.oxc";//控件路径
bool bReg = true;
HINSTANCE hLib = LoadLibraryEx((LPCWSTR)modulePathName.data(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (hLib < (HINSTANCE)HINSTANCE_ERROR)
return false;

//获取注册函数DllRegisterServer地址
FARPROC lpDllEntryPoint;
if (!bReg)
lpDllEntryPoint = GetProcAddress(hLib, "DllUnregisterServer");
else
lpDllEntryPoint = GetProcAddress(hLib, "DllRegisterServer");

//调用注册函数DllRegisterServer
if (lpDllEntryPoint == NULL)
{
FreeLibrary(hLib);
return false;
}
if (FAILED((*lpDllEntryPoint)()))
{
FreeLibrary(hLib);
return false;
}
FreeLibrary(hLib);
return true;

posted @ 2021-09-18 11:25  久龄  阅读(16)  评论(0编辑  收藏  举报