Hello, i try to port a DLL i made in C++ (Win32, without MFC) to Qt but it's a bit hard.
My DLL is loaded by LoadLibrary from a non-Qt application. But even if it's Qt is portable, it have serious problems with some standards of Windows :|
Actually, i just want to load my QtGui and handle it like any Qt application. Since the entry point DllMain must return a value to continue, i thought i should make a thread to load it. Here is my problem. In this code :
#include "test_ui.h"
#include <windows.h>
#include <process.h>
#include <QApplication>
#include <QMessageBox>
void StartThread();
BOOL WINAPI DllMain( HMODULE hModule, DWORD dwReason, LPVOID /*lpvReserved*/ )
{
if (dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hModule);
// MessageBoxA(NULL, "Test DllMain", NULL, NULL);
// QMessageBox::information(0, "Test", "Test Qt");
// QtConcurrent::run(StartThread);
//_beginthread((void(*)(void*))StartThread,NULL,NULL);
}
return TRUE;
}
void StartThread()
{
MessageBoxA(NULL, "app test", "app test", NULL);
}
#include "test_ui.h"
#include <windows.h>
#include <process.h>
#include <QApplication>
#include <QMessageBox>
void StartThread();
BOOL WINAPI DllMain( HMODULE hModule, DWORD dwReason, LPVOID /*lpvReserved*/ )
{
if (dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hModule);
// MessageBoxA(NULL, "Test DllMain", NULL, NULL);
// QMessageBox::information(0, "Test", "Test Qt");
// QtConcurrent::run(StartThread);
//_beginthread((void(*)(void*))StartThread,NULL,NULL);
}
return TRUE;
}
void StartThread()
{
MessageBoxA(NULL, "app test", "app test", NULL);
}
To copy to clipboard, switch view to plain text mode
The MessageBoxA in the DllMain works perfectly, the QMessageBox doesn't, the QtConcurrent neither, and same way for _beginthread.
I tried by the CreateThread function :
printf("TestThr address : 0x%.8X\n", (DWORD)TestThr);
HANDLE hThread = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)TestThr, NULL, NULL, NULL);
printf("CreateThread return : %d - GetLastError : %d\n", hThread, GetLastError());
printf("TestThr address : 0x%.8X\n", (DWORD)TestThr);
HANDLE hThread = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)TestThr, NULL, NULL, NULL);
printf("CreateThread return : %d - GetLastError : %d\n", hThread, GetLastError());
To copy to clipboard, switch view to plain text mode
The console returned me this :
TestThr address : 0x6F761010
CreateThread return : 380 - GetLastError : 6
The GetLastError return ERROR_INVALID_HANDLE while the CreateThread return me an handle, of course the thread is absolutely not loaded ...
I wanted to try with QtWinMigrate (http://qt.gitorious.org/qt-solutions...r/qtwinmigrate), but it's absolutely not for Qt5 cause there is always much errors.
I tried with this code : http://stackoverflow.com/a/11056698
Actually my GUI is loaded EXCEPT :
- The dll don't load into the application it should be, but with another one (AutoIt script) it does
- The GUI events are not handled at all, except if i minimize then maximize the UI (sort of repaint)
Well i think i said everything, i use Qt5 final, building with MSVC2010.
I hope you could help me to get this working.
Bookmarks