mirror of
https://github.com/HIllya51/LunaHook.git
synced 2025-01-11 20:39:34 +08:00
优化qt路径搜索
This commit is contained in:
parent
0a3904df4f
commit
476918a846
@ -11,8 +11,10 @@ extern "C" __declspec(dllexport) HMODULE* QtLoadLibrary(LPCWSTR* dlls,int num){
|
||||
auto hdlls=new HMODULE[num];
|
||||
auto mutex=CreateSemaphoreW(0,0,1,0);
|
||||
std::thread([=](){
|
||||
for(int i=0;i<num;i++)
|
||||
QApplication::addLibraryPath(QString::fromStdWString(std::filesystem::path(dlls[i]).parent_path()));
|
||||
|
||||
int _=0;
|
||||
QApplication::addLibraryPath(QString::fromStdWString(std::filesystem::path(dlls[0]).parent_path()));
|
||||
QApplication app(_, nullptr);
|
||||
app.setFont(QFont("MS Shell Dlg 2", 10));
|
||||
for(int i=0;i<num;i++)
|
||||
|
@ -33,25 +33,21 @@ QtLoadLibrary_t loadqtloader(const std::filesystem::path&pluginpath){
|
||||
auto QtLoadLibrary = (QtLoadLibrary_t)GetProcAddress(helper, "QtLoadLibrary");
|
||||
return QtLoadLibrary;
|
||||
}
|
||||
struct pathhelper{
|
||||
wchar_t currdll[MAX_PATH],currdir[MAX_PATH];
|
||||
pathhelper(LPCWSTR p){
|
||||
GetDllDirectoryW(MAX_PATH,currdll);GetCurrentDirectoryW(MAX_PATH,currdll);
|
||||
SetDllDirectoryW(p);SetCurrentDirectoryW(p);
|
||||
}
|
||||
~pathhelper(){
|
||||
SetDllDirectoryW(currdll);SetCurrentDirectoryW(currdll);
|
||||
}
|
||||
};
|
||||
void Pluginmanager::loadqtdlls(std::vector<std::wstring>&collectQtplugs){
|
||||
if(collectQtplugs.size()==0)return;
|
||||
auto pluginpath=std::filesystem::current_path()/(x64?"plugin64":"plugin32");
|
||||
auto _h=new pathhelper(pluginpath.c_str());//若加载Qt插件,不需要恢复路径,不然会有很多杂乱的文件。
|
||||
wchar_t env[65535];
|
||||
GetEnvironmentVariableW(L"PATH",env,65535);
|
||||
auto envs=std::wstring(env);
|
||||
envs+=L";";envs+=pluginpath;
|
||||
for(auto&p:collectQtplugs){
|
||||
envs+=L";";envs+=std::filesystem::path(p).parent_path();
|
||||
}
|
||||
SetEnvironmentVariableW(L"PATH",envs.c_str());
|
||||
|
||||
auto QtLoadLibrary = loadqtloader(pluginpath);
|
||||
if(!QtLoadLibrary){
|
||||
MessageBoxW(host->winId,CantLoadQtLoader,L"Error",0);
|
||||
delete _h;
|
||||
return ;
|
||||
}
|
||||
std::vector<wchar_t*>saves;
|
||||
|
Loading…
x
Reference in New Issue
Block a user