Mega Code Archive

 
Categories / Delphi / Examples
 

Lock the workstation

Title: lock the workstation? { The LockWorkStation function locks the workstation's display, protecting it from unauthorized use. This function has the same result as pressing Ctrl+Alt+Del and clicking Lock Workstation. To unlock the workstation, the user must log in. Windows NT/2000/XP: Included in Windows 2000 and later. Windows 95/98/Me: Unsupported. } procedure TForm1.Button1Click(Sender: TObject); begin LockWorkStation; end; { Loading LockWorkStation dynamically} function LockWS: Boolean; // by Thomas Stutz, SDC type TLockWorkStation = function: Boolean; var hUser32: HMODULE; LockWorkStation: TLockWorkStation; begin // Here we import the function from USER32.DLL hUser32 := GetModuleHandle('USER32.DLL'); if hUser32 0 then begin @LockWorkStation := GetProcAddress(hUser32, 'LockWorkStation'); if @LockWorkStation nil then begin LockWorkStation; Result := True; end; end; end;