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
LockWorkStation()
LockWorkStation()
To copy to clipboard, switch view to plain text mode
If you want to link during run-time, use QLibrary.
BOOL (*lockWorkStation)();
...
lockWorkStation = user32.resolve("LockWorkStation");
lockWorkStation();
BOOL (*lockWorkStation)();
...
QLibrary user32("user32.dll", this);
lockWorkStation = user32.resolve("LockWorkStation");
lockWorkStation();
To copy to clipboard, switch view to plain text mode
Note that the above dry-coded and might contain errors.
Added after 5 minutes:
Maybe your suggestion could be done using QProcess:
QProcess::execute("rundll32", QStringList("USER32.DLL,LockWorkStation"));
To copy to clipboard, switch view to plain text mode
Bookmarks