srohit24
4th March 2009, 06:25
I am trying to retrieve data from a dll and show it on a console window.
I first tried it out with VC++ and this was the main code
#include <iostream>
#include<windows.h>
using namespace std;
HMODULE hDll = LoadLibrary(L"dllprog.dll");
FARPROC fpTestDll = GetProcAddress(hDll, "TestDll");
typedef char* (__stdcall *fpTestDllT)();
fpTestDllT TestDll = (fpTestDllT)fpTestDll;
int main()
{
char* a;
a = TestDll();
cout <<endl << a;
Sleep(3000);
}
this is working perfectly fine.
Now i am trying to write the same thing with Qt using QtCreator to make it platform independent
this is my code
#include <QtCore/QCoreApplication>
#include <QLibrary>
#include <iostream>
#include <windows.h>
QLibrary myLib("dllprog");
typedef void (*MyPrototype)();
MyPrototype myFunction =
(MyPrototype) QLibrary::resolve("dllprog", "TestDll");
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
char b;
b = TestDll();
cout <<endl << b;
return a.exec();
}
but the compiler shows some errors. what changes should I make to get the app working??
One more question, i tried a helloworld dialog app. It was working fine when i used the creator to build and run, but when i went to the .exe file and double clicked it, it says mingwm10.dll is missing. I have given the path os MINGW in the environmental variables. what should I do to avoid that?
Will the created app be able to run in systems that dont have MINGW?
I first tried it out with VC++ and this was the main code
#include <iostream>
#include<windows.h>
using namespace std;
HMODULE hDll = LoadLibrary(L"dllprog.dll");
FARPROC fpTestDll = GetProcAddress(hDll, "TestDll");
typedef char* (__stdcall *fpTestDllT)();
fpTestDllT TestDll = (fpTestDllT)fpTestDll;
int main()
{
char* a;
a = TestDll();
cout <<endl << a;
Sleep(3000);
}
this is working perfectly fine.
Now i am trying to write the same thing with Qt using QtCreator to make it platform independent
this is my code
#include <QtCore/QCoreApplication>
#include <QLibrary>
#include <iostream>
#include <windows.h>
QLibrary myLib("dllprog");
typedef void (*MyPrototype)();
MyPrototype myFunction =
(MyPrototype) QLibrary::resolve("dllprog", "TestDll");
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
char b;
b = TestDll();
cout <<endl << b;
return a.exec();
}
but the compiler shows some errors. what changes should I make to get the app working??
One more question, i tried a helloworld dialog app. It was working fine when i used the creator to build and run, but when i went to the .exe file and double clicked it, it says mingwm10.dll is missing. I have given the path os MINGW in the environmental variables. what should I do to avoid that?
Will the created app be able to run in systems that dont have MINGW?