How to lock/ unlock Windows PC using Qt pro-gramatically?
I need to lock/ unlock PC (Windows O/S) with Qt pro-grammatically. Is their any direct API/ functions available for this? Any possible way to do this?
You can use the native API directly from your Qt application. Qt apps are just C++, and you can use native API just fine. No need for a separate application, your app just won’t be portable to other platforms such a Linux and Mac if you do this, but given the task, I guess that is not an issue for you. If you want to interact with external applications, you can look into QProcess though.
well, i found the link http://msdn.microsoft.com/en-us/library/aa376869(v=vs.85).aspx to lock the PC using VC++/ C#. So, you want to say that this code can be directly used in Qt?
To cite MSDN at http://msdn.microsoft.com/en-us/library/7f0aews7(VS.80).aspx
The comment-type is one of the predefined identifiers, described below, that specifies the type of comment record. The optional commentstring is a string literal that provides additional information for some comment types. Because commentstring is a string literal, it obeys all the rules for string literals with respect to escape characters, embedded quotation marks (”), and concatenation.
Places a library-search record in the object file. This comment type must be accompanied by a commentstring parameter containing the name (and possibly the path) of the library that you want the linker to search. The library name follows the default library-search records in the object file; the linker searches for this library just as if you had named it on the command line provided that the library is not specified with /nodefaultlib. You can place multiple library-search records in the same source file; each record appears in the object file in the same order in which it is encountered in the source file.
If the order of the default library and an added library is important, compiling with the /Zl switch will prevent the default library name from being placed in the object module. A second comment pragma then can be used to insert the name of the default library after the added library. The libraries listed with these pragmas will appear in the object module in the same order they are found in the source code.
So it should be sufficient to add to your .pro:
- LIBS += user32.lib
- // or
- LIBS += -luser32