implementing windows function in qt
hi..
i'm trying to convert vc++ code into QT.
in Vc++the code calls inbuilt function GetProcAddress ()
After searching on google, i found some info about it.
Quote:
GetProcAddress ()
Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL).
Syntax
C++
FARPROC WINAPI GetProcAddress(
__in HMODULE hModule,
__in LPCSTR lpProcName
);
I'm not sure about it i.e (GetProcAddress is windows function)
Correct if i'm wrong.
How can the same function be implemented in Qt ?
Re: implementing windows function in qt
If there's GetProcAddress, there will no doubt be LoadLibrary too somewhere, in which case, take a look at http://doc.trolltech.com/4.5/qlibrary.html
In particular, GetProcAddress should match to the 'resolve' function quite nicely.
Re: implementing windows function in qt
There is no need to implement your own function for GetProcAddress
Qt also provide the dll loading functinality through QLibrary class
you can look into this class..
here is a sample code for the same.......
QLibrary library( "dll_Name" );
library.resolve("Function_Name"); // same as GetProcAddress
I hope it will resolve your problem
Re: implementing windows function in qt
Is there any example of Qt In which dll is used.
When I load a dll by using GetProcAddress() I had get error i.e. function is not declare.
Can anyone have any Idea to solve this problem or small example of How to use dll in Qt.
Re: implementing windows function in qt
If GetProcAddress doesn't work for you, then Qt resolv function is unlikely to work either.
But here goes:
Code:
typedef void (*proto)();
proto func = (proto) lib.resolve("dosomething");
you can then use 'func' as a normal function pointer, ie: func()
Note that you do not need the '.DLL' part of the library. This is assumed automatically and makes the code more portable (ie, when compiled under Linux, it will automatically add '.so' instead)