urif
asked on
Lock the workstation on a windows machine
hi,
i'm trying to come by some code to help me lock the workstation from the program i'm developing for windows machines (2000 and xp)
i know there is an API, but i think i don't have it, for example i tried this:
#include <windows.h>
#include <stdio.h>
int main()
{
if(!LockWorkStation())
printf ("error: could not lock workstation: %d\n", GetLastError());
return 0;
}
according to msdn LockWorkStation() is included on windows.h, but not VC 5, nor GCC (mingw or cygwin) can find it.
another thing i tried is to find something similar to this:
SendMessage(HWND_BROADCAST ,WM_SYSCOM MAND,SC_SC REENSAVE,0 );
that will lock the workstation by activating the screensaver. everything is fine, only i just want to lock the computer without the screensaver. so maybe there is a parameter other than SC_SCREENSAVE that i can pass onto SendMessage.
the last thing i know of is the rundll trick of locking the Workstation by calling user32.dll or something, but again, there must be a better way
any ideas?
any help will be appreciated.
i'm trying to come by some code to help me lock the workstation from the program i'm developing for windows machines (2000 and xp)
i know there is an API, but i think i don't have it, for example i tried this:
#include <windows.h>
#include <stdio.h>
int main()
{
if(!LockWorkStation())
printf ("error: could not lock workstation: %d\n", GetLastError());
return 0;
}
according to msdn LockWorkStation() is included on windows.h, but not VC 5, nor GCC (mingw or cygwin) can find it.
another thing i tried is to find something similar to this:
SendMessage(HWND_BROADCAST
that will lock the workstation by activating the screensaver. everything is fine, only i just want to lock the computer without the screensaver. so maybe there is a parameter other than SC_SCREENSAVE that i can pass onto SendMessage.
the last thing i know of is the rundll trick of locking the Workstation by calling user32.dll or something, but again, there must be a better way
any ideas?
any help will be appreciated.
ASKER
hmmm, thanks but i dont think that installing a 266mb sdk for one function is a solution. at least not at this point.
thanks so much anyway
any other ideas?
thanks so much anyway
any other ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it still returns as undeclared identifier: _LockWorkStation();
ASKER
ok for anyone that searched the solution:
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <winuser.h>
so you only have to add winuser.h
cheers!
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <winuser.h>
so you only have to add winuser.h
cheers!
You need install VC7 or try this one
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/