📄 frmmainunit.pas
字号:
ListView4.Selected.MakeVisible(False);
ListView4.SetFocus;
end
else if (not LI.Checked) and (LI.Caption[1]<>';') then
begin
ListView4.Selected:=LI;
oldIndex:=ListView4.ItemIndex;
ChangeLine('System.ini',Pchar(LI.Caption),Pchar(';' + LI.Caption));
ScanSystemINI('System.ini');
ListView4.ItemIndex:=oldIndex;
ListView4.Selected.MakeVisible(False);
ListView4.SetFocus;
end;
end;
end;
Procedure TFrmMain.ChangeLine(iniFN:string;oldL:Pchar;newL:Pchar);
var
F1, F2: TextFile;
St: String;
WinDir: array[1..MAX_PATH] of char;
begin
if GetWindowsDirectory(Pchar(@WinDir),MAX_PATH)=0 then
begin
MessageBox(Handle,'Error get Windows Dir!','Scan INI files...',MB_ICONEXCLAMATION);
exit;
end;
AssignFile(F1, Pchar(@WinDir) + '\' + iniFN);
Reset(F1);
AssignFile(F2, Pchar(@WinDir) + '\' + iniFN + '.new');
Rewrite(F2);
while not Eof(F1) do
begin
Readln(F1, St);
St:=strlower(Pchar(trim(st)));
if st=oldL then st:=newL;
Writeln(F2, St);
end;
CloseFile(F1);
CloseFile(F2);
Deletefile(Pchar(@WinDir) + '\' + iniFN);
MoveFile(Pchar(Pchar(@WinDir) + '\' + iniFN + '.new'),Pchar(Pchar(@WinDir) + '\' + iniFN));
end;
procedure TfrmMain.ListView5MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
LI:TListItem;
oldIndex: Integer;
begin
LI:=ListView5.GetItemAt(x,y);
if LI<>nil then
begin
if (LI.Checked) and (LI.Caption[1]=';') then
begin
ListView5.Selected:=LI;
oldIndex:=ListView5.ItemIndex;
ChangeLine('Win.ini',Pchar(LI.Caption),Pchar(LI.Caption)+1);
ScanSystemINI('Win.ini');
ListView5.ItemIndex:=oldIndex;
ListView5.Selected.MakeVisible(False);
ListView5.SetFocus;
end
else if (not LI.Checked) and (LI.Caption[1]<>';') then
begin
ListView5.Selected:=LI;
oldIndex:=ListView5.ItemIndex;
ChangeLine('Win.ini',Pchar(LI.Caption),Pchar(';' + LI.Caption));
ScanSystemINI('Win.ini');
ListView5.ItemIndex:=oldIndex;
ListView5.Selected.MakeVisible(False);
ListView5.SetFocus;
end;
end;
end;
procedure TfrmMain.cmdSysEditClick(Sender: TObject);
begin
if ShellExecute(handle, 'Open','Sysedit.exe' , nil, nil, SW_SHOW)<=32 then
MessageBox(Handle,'Error run Sysedit.exe!', 'Run System Ini file editor',MB_ICONEXCLAMATION);
end;
procedure TfrmMain.cmdMSConfigClck(Sender: TObject);
begin
if ShellExecute(handle, 'Open','msconfig.exe' , nil, nil, SW_SHOW)<=32 then
MessageBox(Handle,'Error run msconfig.exe!' + #13 + 'Your OS must be Windows 9x or XP!', 'Run MS Config',MB_ICONEXCLAMATION);
end;
procedure TfrmMain.cmdServiceManClick(Sender: TObject);
begin
if ShellExecute(handle, 'Open','services.msc' , '/s', nil, SW_SHOW)<=32 then
MessageBox(Handle,'Error run services.msc!' + #13 + 'Your OS must be Windows 2000/XP!', 'Run services.msc',MB_ICONEXCLAMATION);
end;
procedure TfrmMain.cmdRegeditClick(Sender: TObject);
begin
if ShellExecute(handle, 'Open','regedit.exe' , nil, nil, SW_SHOW)<=32 then
MessageBox(Handle,'Error run regedit.exe!', 'Run regedit.exe',MB_ICONEXCLAMATION);
end;
procedure TfrmMain.BitBtn1Click(Sender: TObject);
begin
Close
end;
Procedure TfrmMain.ChangeCmdStatus(booAllStatus: Boolean;LI: TListItem);
Begin
if li=nil then
begin
cmdServiceRestart.Enabled:=False;
cmdServiceStop.Enabled:=False;
cmdServiceStart.Enabled:=False;
cmdServiceChangeStartupMode.Enabled:=False;
exit;
end;
with LI do
if (not booAllStatus) or (LI.SubItems.Count<2) then
begin
cmdServiceRestart.Enabled:=False;
cmdServiceStop.Enabled:=False;
cmdServiceStart.Enabled:=False;
cmdServiceChangeStartupMode.Enabled:=False;
end
else
begin
if (SubItems[2]='Disabled') or (Caption='PSMAntiSpy') then
begin
cmdServiceStop.Enabled:=False;
cmdServiceStart.Enabled:=False;
cmdServiceRestart.Enabled:=False;
if (Caption='PSMAntiSpy') then
cmdServiceChangeStartupMode.Enabled:=False
else
cmdServiceChangeStartupMode.Enabled:=true;
end
else
begin
if SubItems[1]='Running' then
begin
cmdServiceStop.Enabled:=True;
cmdServiceStart.Enabled:=False;
cmdServiceRestart.Enabled:=True;
end
else
begin
cmdServiceStop.Enabled:=False;
cmdServiceStart.Enabled:=True;
cmdServiceRestart.Enabled:=False;
end;
cmdServiceChangeStartupMode.Enabled:=True;
end
end;
End;
procedure TfrmMain.cmdServiceStartClick(Sender: TObject);
Var oldSt: String;
begin
ChangeCmdStatus(False,ListView2.Selected);
oldSt:=ListView2.Selected.SubItems[1];
ListView2.Selected.SubItems[1]:='';
TabSheet2.Cursor:=crHourGlass;
ListView2.Enabled:=False;
ListView2.Refresh;
if ServiceStart('', ListView2.Selected.SubItems[3]) then
ListView2.Selected.SubItems[1]:='Running'
else
ListView2.Selected.SubItems[1]:=oldSt;
ChangeCmdStatus(True,ListView2.Selected);
ListView2.Enabled:=True;
ListView2.SetFocus;
TabSheet2.Cursor:=crDefault;
end;
procedure TfrmMain.cmdServiceStopClick(Sender: TObject);
Var oldSt: String;
begin
ChangeCmdStatus(False,ListView2.Selected);
oldSt:=ListView2.Selected.SubItems[1];
ListView2.Selected.SubItems[1]:='';
TabSheet2.Cursor:=crHourGlass;
ListView2.Enabled:=False;
ListView2.Refresh;
if ServiceStop('', ListView2.Selected.SubItems[3]) then
ListView2.Selected.SubItems[1]:='Stopped'
else
ListView2.Selected.SubItems[1]:=oldSt;
ChangeCmdStatus(True,ListView2.Selected);
ListView2.Enabled:=True;
ListView2.SetFocus;
TabSheet2.Cursor:=crDefault;
end;
procedure TfrmMain.cmdServiceRestartClick(Sender: TObject);
begin
cmdServiceStopClick(Sender);
cmdServiceStartClick(Sender);
end;
procedure TfrmMain.mnuServiceStartupTypeClick(Sender: TObject);
Var
oldSt: String;
newSt: String;
mnu: TMenuItem;
dwStartType: DWORD;
begin
mnu:=Sender as TMenuItem;
ChangeCmdStatus(False,ListView2.Selected);
oldSt:=ListView2.Selected.SubItems[2];
ListView2.Selected.SubItems[2]:='';
TabSheet2.Cursor:=crHourGlass;
ListView2.Enabled:=False;
ListView2.Refresh;
if mnu.Caption='&Automatic' then
begin
dwStartType:=SERVICE_AUTO_START;
newSt:='Automatic';
end
else if mnu.Caption='&Manual' then
begin
dwStartType:=SERVICE_DEMAND_START;
newSt:='Manual';
end
else
begin
dwStartType:=SERVICE_DISABLED;
newSt:='Disabled';
end;
if ChangeServiceStartType('', ListView2.Selected.SubItems[3],dwStartType) then
ListView2.Selected.SubItems[2]:=newSt
else
ListView2.Selected.SubItems[2]:=oldSt;
ChangeCmdStatus(True,ListView2.Selected);
ListView2.Enabled:=True;
ListView2.SetFocus;
TabSheet2.Cursor:=crDefault;
end;
procedure TfrmMain.cmdServiceChangeStartupModeClick(Sender: TObject);
var p: TPoint;
begin
ListView2.SetFocus;
GetCursorPos(p);
PopupMenu2.Popup(p.X,p.Y);
end;
procedure TfrmMain.ListView2DblClick(Sender: TObject);
var
sei: TShellExecuteInfo;
path: string;
begin
if ListView2.Selected<>nil then
begin
path:=ListView2.Selected.SubItems[0];
path:=trim(path);
if path<>'' then
begin
if path[1]='"' then begin path[1]:=' ';path:=trim(path);end;
if StrPos(Pchar(Path),'"')<>nil then
StrPos(Pchar(Path),'"')[0]:=#0
else if StrPos(Pchar(Path),'.exe')<>nil then
StrPos(Pchar(Path),'.exe')[4]:=#0
else if StrPos(Pchar(Path),' ')<>nil then
StrPos(Pchar(Path),' ')[0]:=#0;
ListView2.Cursor:=crHourGlass;
FillChar(sei, SizeOf(sei), 0);
sei.cbSize := SizeOf(sei);
sei.lpFile := PChar(path);
sei.lpVerb := 'properties';
sei.fMask := SEE_MASK_INVOKEIDLIST;
sei.Wnd:=Handle;
ShellExecuteEx(@sei);
Wait(500);
ListView2.Cursor:=crDefault;
end;
end;
end;
procedure TfrmMain.ListView2SelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
var LI:TListItem;
begin
LI:=ListView2.Selected;
if LI<>nil then
ChangeCmdStatus(true,LI)
else
ChangeCmdStatus(false,LI);
end;
Procedure TfrmMain.DelKBf();
var
reg: Tregistry;
tmp1:array[1..MAX_PATH] of char;
tmp2:array[1..MAX_PATH] of char;
tmp:Pchar;
i,l: word;
myhKey: HKEY;
lRes: Longint;
oldCaption:string;
oldFile:string;
Begin
if ListView3.Selected=nil then exit;
with ListView3 do
begin
Reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_LOCAL_MACHINE;
if Reg.OpenKey('SYSTEM\CurrentControlSet\Control\Class\{4D36E96B-E325-11CE-BFC1-08002BE10318}',False) then
Begin
FillChar(tmp1, MAX_PATH, Ord(' '));
FillChar(tmp2, MAX_PATH, Ord(#0));
reg.ReadBinaryData('UpperFilters',tmp1,MAX_PATH);
if trim(tmp1)<>'' then
begin
StrCat(Pchar(@tmp2),Pchar(@tmp1));
StrCat(Pchar(@tmp2),':');
end;
i:=1;
while (i< MAX_PATH) do
begin
i:=i+1;
if tmp1[i]=#0 then
begin
if tmp1[i+1]=#0 then break;
while (tmp1[i]=#0)and (i<MAX_PATH) do i:=i+1;
if i<MAX_PATH then
begin
tmp:=Pchar(@tmp1[i]);
tmp:=Pchar(trim(string(tmp)));
i:=i+strlen(tmp)-1;
if (tmp<>'')and(tmp<>ListView3.Selected.Caption) then
StrCat(Pchar(@tmp2),Pchar(tmp + ':'));
end;
end;
end;{while}
StrCat(Pchar(@tmp2),':');
l:=StrLen(Pchar(@tmp2));
for i:=1 to l do if tmp2[i]=':' then tmp2[i]:=#0;
//ShowMessage(Pchar(@tmp2));
//Tregistry of Delphi does not support REG_MULTI_SZ, huhu!!!
lRes := RegOpenKeyEx(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Class\{4D36E96B-E325-11CE-BFC1-08002BE10318}', 0, KEY_WRITE, myhKey);
if lRes=ERROR_SUCCESS then
if MessageBox(Handle,Pchar('Disable [' + ListView3.Selected.Caption + '] ?'),'This action can not be undone!',MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2)=IDYES then
begin
oldCaption:=Selected.Caption;
oldFile:=Selected.SubItems[0];
RegSetValueEx(myhKey, 'UpperFilters', 0, REG_MULTI_SZ, @tmp2, l);
RegCloseKey(myhKey);
ScanKeyboardFilterDriver;
for i:=0 to ListView3.Items.Count-1 do
if ListView3.Items[i].Caption=oldCaption then
begin
oldFile:='';
break;
end;
if oldFile<>'' then RenameFile(oldFile, oldFile + '.del');
end;
//
end;
finally
Reg.free;
end;
end;
End;
procedure TfrmMain.TrapMSG(var MSGX: TMessage);
begin
if MSGX.Msg=WM_USER+9 then//Exit message
Application.Terminate
else WndProc(MSGX);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -