Lockworkstation functions simulated in non-XP operating systems
Author: delphiscn
Information Source: evil baboons Information Security Team
Program functions: computers that can be specified in non-XP operating systems
(For the beautiful UI of the program, I used the suipack control. If you are interested, you can download it from delphibox.com)
**************************************** **********************
Application password: Administrators
**************************************** **********************
Unit unit1;
Interface
Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, extctrls, suiform, stdctrls, suiedit, suibutton, inifiles, suidlg;
Type
Tform1 = Class (tform)
Form1: tsuiform;
Inputpassword: tsuiedit;
OK: tsuibutton;
Changepassword: tsuibutton;
Savepassword: tsuibutton;
Passwordnew: tsuiedit;
Closeapplication: tsuibutton;
Notes: tlabel;
Message: tsuimessagedialog;
Procedure formkeydown (Sender: tobject; var key: word;
Shift: tshiftstate );
Procedure okclick (Sender: tobject );
Procedure formcreate (Sender: tobject );
Procedure savepasswordclick (Sender: tobject );
Procedure closeapplicationclick (Sender: tobject );
Procedure changepasswordclick (Sender: tobject );
Private
{Private Declarations}
Public
{Public declarations}
End;
VaR
Form1: tform1;
Implementation
{$ R *. DFM}
Procedure tform1.formkeydown (Sender: tobject; var key: word;
Shift: tshiftstate );
Begin
If (Key = vk_f4) and ([ssalt] = Shift) then key: = 0;
End;
Procedure lock;
VaR
Hdesktop: thandle;
Wndhandle: thandle;
Wndclass: array [0 .. 50] of char;
Begin
Hdesktop: = findwindow ('progman ', nil );
Showwindow (hdesktop, sw_hide );
Strpcopy (@ wndclass [0], 'Shell _ traywnd ');
Wndhandle: = findwindow (@ wndclass [0], nil );
Showwindow (wndhandle, sw_hide );
End;
Procedure unlock;
VaR
Hdesktop: thandle;
Wndhandle: thandle;
Wndclass: array [0 .. 50] of char;
Begin
Hdesktop: = findwindow ('progman ', nil );
Showwindow (hdesktop, sw_show );
Strpcopy (@ wndclass [0], 'Shell _ traywnd ');
Wndhandle: = findwindow (@ wndclass [0], nil );
Showwindow (wndhandle, sw_show );
End;
Procedure tform1.okclick (Sender: tobject );
VaR
Filename: string;
Reguser: Tinifile;
Begin
Filename: = extractfilepath (paramstr (0) + 'reguser. ini ';
Reguser: = Tinifile. Create (filename );
If reguser. readstring ('program parameter ', 'Password', '') = inputpassword. Text
Then
Begin
Unlock;
Changepassword. Enabled: = true;
Closeapplication. Enabled: = true;
End
Else
Begin
Message. Text: = 'Sorry your password not right ';
Message. showmodal;
End;
End;
Procedure tform1.formcreate (Sender: tobject );
Begin
Changepassword. Enabled: = false;
Passwordnew. Enabled: = false;
Closeapplication. Enabled: = false;
Notes. Enabled: = false;
Savepassword. Enabled: = false;
Lock;
End;
Procedure tform1.savepasswordclick (Sender: tobject );
VaR
Filename: string;
Reguser: Tinifile;
Begin
Filename: = extractfilepath (paramstr (0) + 'reguser. ini ';
Reguser: = Tinifile. Create (filename );
Reguser. writestring ('program parameter ', 'Password', passwordnew. Text );
Message. Text: = 'you have changed password ';
Message. showmodal;
End;
Procedure tform1.closeapplicationclick (Sender: tobject );
Begin
Close;
End;
Procedure tform1.changepasswordclick (Sender: tobject );
Begin
Notes. Enabled: = true;
Passwordnew. Enabled: = true;
Savepassword. Enabled: = true;
End;
End.
Reguser. ini
---------------------------------------------------------------------------------
[Program parameters]
Password = Administrators
---------------------------------------------------------------------------------
Call lockworkstation function in XP
Rundll32.exe user32.dll, lockworkstation