2024-02-09 09:25:26 +08:00
|
|
|
#include<Windows.h>
|
|
|
|
#include<QApplication>
|
|
|
|
#include<QFont>
|
|
|
|
#include<QDir>
|
|
|
|
#include<thread>
|
|
|
|
#include<mutex>
|
|
|
|
#include<Shlwapi.h>
|
2024-02-09 19:38:12 +08:00
|
|
|
#include<filesystem>
|
2024-02-09 09:25:26 +08:00
|
|
|
|
|
|
|
extern "C" __declspec(dllexport) HMODULE* QtLoadLibrary(LPCWSTR* dlls,int num){
|
|
|
|
auto hdlls=new HMODULE[num];
|
|
|
|
auto mutex=CreateSemaphoreW(0,0,1,0);
|
|
|
|
std::thread([=](){
|
2024-02-09 19:38:12 +08:00
|
|
|
int _=0;
|
|
|
|
QApplication::addLibraryPath(QString::fromStdWString(std::filesystem::path(dlls[0]).parent_path()));
|
|
|
|
QApplication app(_, nullptr);
|
2024-02-09 09:25:26 +08:00
|
|
|
app.setFont(QFont("MS Shell Dlg 2", 10));
|
|
|
|
for(int i=0;i<num;i++)
|
|
|
|
hdlls[i]=LoadLibraryW(dlls[i]);
|
|
|
|
ReleaseSemaphore(mutex,1,0);
|
|
|
|
app.exec();
|
|
|
|
|
|
|
|
}).detach();
|
|
|
|
WaitForSingleObject(mutex,INFINITE);
|
|
|
|
return hdlls;
|
|
|
|
}
|