Here is how you can check and see if Windows is locked in Qt/C++. This same function will also let you know if the user is switched to another. Note that this involves using some Win32 API functions.
Note that you need to add the following include header to your code:
And also the following library to your .PRO file:
LIBS += -lUser32
Here is the function that will check for user locked state:
HDESK desktop = OpenDesktop(TEXT(“Default”), 0, false, DESKTOP_SWITCHDESKTOP);
Or use the following snippet from my Bitbucket: