Check windows workstation is locked or not
-
Hi Friends, I have written below code for checking whether windows machine is locked or not but its gives always window is locked though its not locked. Could anyone suggest what is wrong here or can give alternative solution? bool lockedHost = false; HMODULE hUser32; FARPROC LockWorkStation; hUser32 = GetModuleHandle("user32.dll"); if (hUser32) { LockWorkStation = GetProcAddress(hUser32, "LockWorkStation"); if (LockWorkStation) { lockedHost = true; MessageBox(0, "locked1", "Info", MB_OK); } } Thanks in advanced, Paresh
-
Hi Friends, I have written below code for checking whether windows machine is locked or not but its gives always window is locked though its not locked. Could anyone suggest what is wrong here or can give alternative solution? bool lockedHost = false; HMODULE hUser32; FARPROC LockWorkStation; hUser32 = GetModuleHandle("user32.dll"); if (hUser32) { LockWorkStation = GetProcAddress(hUser32, "LockWorkStation"); if (LockWorkStation) { lockedHost = true; MessageBox(0, "locked1", "Info", MB_OK); } } Thanks in advanced, Paresh
Though I don't know how to check whether the workstation is locked or not. But I do know what wrong with your code! 1、
LockWorkStation = GetProcAddress(hUser32, "LockWorkStation");
Only return the function pointer of "LockWorkStation".Then you can use this function! 2、LockWorkStation is the function to lock workstation, not to check whether the workstation is locked or not. Do check MSDN! Gurus may answer your question! -
Hi Friends, I have written below code for checking whether windows machine is locked or not but its gives always window is locked though its not locked. Could anyone suggest what is wrong here or can give alternative solution? bool lockedHost = false; HMODULE hUser32; FARPROC LockWorkStation; hUser32 = GetModuleHandle("user32.dll"); if (hUser32) { LockWorkStation = GetProcAddress(hUser32, "LockWorkStation"); if (LockWorkStation) { lockedHost = true; MessageBox(0, "locked1", "Info", MB_OK); } } Thanks in advanced, Paresh
Check out this link - http://stackoverflow.com/questions/44980/how-can-i-programmatically-determine-if-my-workstation-is-locked[^]. Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
modified on Sunday, November 23, 2008 7:15 AM