Current
| Archives
| Contact
Me
Related
Links | My
Personal Journal | Diaryland
�Delphi code to see if a Windows 2000/XP workstation is locked� Ever wanted to check if a workstation is locked in Delphi? So did I, that's why I wrote this. The following code will check to see if a Windows 2000/XP Pro workstation is locked. I haven't tested it under Windows NT or any other OSes. If you use it, I don't imply any warranties of any kind and you assume all responsibilities. Caveat: I don't know what this does under fast user switching under XP. Personally, for the environment I write code for and the uses this is intended for, I don't care. If you test it and have input about that, I'd be glad to post some information about that. Be sure to add the units Windows and Variants to your Uses listing. function WorkstationLocked: boolean; var hd: HDESK; dwLN: dword; pszIN: array [0..255] of char; s: string; begin hd := OpenInputDesktop(0, False, 0); if hd = null then begin WorkstationLocked := False; Exit; end; dwLN := 0; if not GetUserObjectInformation(hd, UOI_NAME, @pszIN, 256, dwLN) then begin WorkstationLocked := True; Exit; end; CloseDesktop(hd); s := AnsiLowerCase(Trim(Copy(pszIN, 0, 256))); WorkstationLocked := (s = 'winlogon'); end; Yes, I edited this after the fact. Don't you hate when you look at your code not more than six hours later and go, "why didn't I see that before?" Both work, this one is just a bit more brief. Now if only I can remember to incorporate this change tomorrow at work...
|
||||||||||||
| ||||||||||||