Calling external DLL function with Qt
Hi all,
I bet this is an old question, and I did some research at StackOverflow and Google, however, I ended up more confused.
How do I simply call a dll function? without linking the dll or other mumbojumbo :)
something like:
Code:
rundll32 USER32.DLL,LockWorkStation
Thank you.
Re: Calling external DLL function with Qt
To run a dll function you need to link against it, either at compile/link time or at run time. At build time you can configure your linker to link against user32.lib, which will automatically resolve the function for you. You can then just call
If you want to link during run-time, use QLibrary.
Code:
BOOL (*lockWorkStation)();
...
lockWorkStation = user32.resolve("LockWorkStation");
lockWorkStation();
Note that the above dry-coded and might contain errors.
Added after 5 minutes:
Maybe your suggestion could be done using QProcess:
Re: Calling external DLL function with Qt
Any Win32 GUI app is already linked to User32.dll so you should be able to just call LockWorkstation() directly with no extra effort.