📄 mainform.pas
字号:
end;
procedure TForm1.lvServiceCompare(Sender: TObject; Item1, Item2: TListItem;Data: Integer; var Compare: Integer);
var
SortFlag: Integer;
begin
if FAscending[2] then SortFlag :=1 else SortFlag :=-1;
case Data of
-1: Compare :=SortFlag * AnsiCompareText(Item1.Caption, Item2.Caption);
0, 1: begin Compare :=SortFlag * AnsiCompareText(Item1.SubItems[Data], Item2.SubItems[Data]) end;
2: Compare :=SortFlag * AnsiCompareText(Item1.SubItems[Data], Item2.SubItems[Data]);
end;
end;
procedure TForm1.lvProcessColumnClick(Sender: TObject;Column: TListColumn);
begin
if FPrevIndex[1] <> Column.Index then FAscending[1] :=True;
lvProcess.CustomSort(nil, Column.Index - 1);
FAscending[1] :=not FAscending[1];
FPrevIndex[1] :=Column.Index;
end;
procedure TForm1.lvProcessCompare(Sender: TObject; Item1, Item2: TListItem;Data: Integer; var Compare: Integer);
var
SortFlag: Integer;
begin
if FAscending[1] then SortFlag :=1 else SortFlag :=-1;
case Data of
-1: Compare :=SortFlag * AnsiCompareText(Item1.Caption, Item2.Caption);
0, 1: begin Compare :=SortFlag * AnsiCompareText(Item1.SubItems[Data], Item2.SubItems[Data]) end;
2: Compare :=SortFlag * AnsiCompareText(Item1.SubItems[Data], Item2.SubItems[Data]);
end;
end;
procedure TForm1.tvtcpudpColumnClick(Sender: TObject; Column: TListColumn);
begin
if FPrevIndex[3] <> Column.Index then FAscending[3] :=True;
tvtcpudp.CustomSort(nil, Column.Index - 1);
FAscending[3] :=not FAscending[3];
FPrevIndex[3] :=Column.Index;
end;
procedure TForm1.tvtcpudpCompare(Sender: TObject; Item1, Item2: TListItem;Data: Integer; var Compare: Integer);
var
SortFlag: Integer;
begin
if FAscending[3] then SortFlag :=1 else SortFlag :=-1;
case Data of
-1: Compare :=SortFlag * AnsiCompareText(Item1.Caption, Item2.Caption);
0, 1:;/// begin Compare :=SortFlag * AnsiCompareText(Item1.SubItems[2], Item2.SubItems[Data]) end;
2: Compare :=SortFlag * AnsiCompareText(Item1.SubItems[Data], Item2.SubItems[Data]);
end;
end;
procedure TForm1.FlatButton3Click(Sender: TObject);
var FileName:string;
begin
FileName:=GetSaveName('ProcessList');
if FileName<>'' then WriteProcessToFile(lvProcess,FileName);
FlatTitlebarBotton.Caption:='保存进程列表';
end;
procedure TForm1.FlatButton4Click(Sender: TObject);
var FileName:string;
begin
FileName:=GetSaveName('ServiceList');
if FileName<>'' then WriteServiceToFile(lvService,FileName);
FlatTitlebarBotton.Caption:='保存服务列表';
end;
procedure TForm1.FlatButton5Click(Sender: TObject);
var FileName:string;
begin
FileName:=GetSaveName('TcpUdpList');
if FileName<>'' then WriteTCPUDPToFile(tvtcpudp,FileName);
FlatTitlebarBotton.Caption:='保存网络列表';
end;
procedure TForm1.pmProcessPopup(Sender: TObject);
begin //点击鼠标右键时的过程
if (lvProcess.SelCount=0) then exit;
ClosebyPID.Caption := '结束所有PID为: '+lvProcess.Selected.Subitems[0]+'的进程';
ClosebyName.Caption:= '结束所有名称为:'+lvProcess.Selected.Caption+'的进程';
end;
procedure TForm1.pmServicePopup(Sender: TObject);
begin //点击鼠标右键时的过程
if (lvService.SelCount=0) then exit;
if (lvService.Selected.SubItems[1]='启用') then
begin
tmStartservice.Enabled := False;
tmStopService.Enabled := True;
end else
begin
tmStartservice.Enabled := True;
tmStopService.Enabled := False;
end;
end;
///////////////////////进程管理、系统服务、网络状态管理的所有过程结束////////////////////////////////////////
///////////////////////系统自启动程序管理的所有过程开始,其中调用的主要过程在StartUpManger单元中//////////////
procedure TForm1.BootListResize(Sender: TObject);
begin
BootList.Items.Clear;
AddDirProgramToList(Globals.SearchAllFile(Get_REGSTR_PATH(CSIDL_COMMON_STARTUP),'*.*'),'1',BootList);
AddDirProgramToList(Globals.SearchAllFile(Get_REGSTR_PATH(CSIDL_STARTUP),'*.*'),'2',BootList);
AddRegProgramToList(HKEY_LOCAL_MACHINE, '\Software\Microsoft\Windows\CurrentVersion\Run','3',BootList);
AddRegProgramToList(HKEY_LOCAL_MACHINE, '\Software\Microsoft\Windows\CurrentVersion\RunOnce','5',BootList);
AddRegProgramToList(HKEY_LOCAL_MACHINE, '\Software\Microsoft\Windows\CurrentVersion\RunServices','7',BootList);
AddRegProgramToList(HKEY_LOCAL_MACHINE, '\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce', '9',BootList);
AddRegProgramToList(HKEY_CURRENT_USER, '\Software\Microsoft\Windows\CurrentVersion\Run','11',BootList);
AddRegProgramToList(HKEY_CURRENT_USER, '\Software\Microsoft\Windows\CurrentVersion\RunOnce','13',BootList);
FlatTitlebarBotton.Caption:='刷新列表';
end;
procedure TForm1.BootListSelectItem(Sender: TObject; Item: TListItem;Selected: Boolean);
begin
if Assigned(BootList.Selected) then
begin
delbtn.Enabled:=True;
Runbtn.Enabled:=True;
Propertiesbtn.Enabled:=True;
ImageSetupIco.Picture.Icon.Handle:=GetFileIcon(PChar(ClearFilePath(BootList.Selected.SubItems[0])),True);
if Pos('注册表',BootList.Selected.SubItems[2])<>0 then Disablebtn.Enabled:=True else Disablebtn.Enabled:=False;
if BootList.Selected.Checked then Disablebtn.Caption:='禁用(&D)' else Disablebtn.Caption:='启用(&D)';
StatusBarStartUp.simpletext:=BootList.Selected.SubItems[1];
end else
begin
delbtn.Enabled:=False;
Runbtn.Enabled:=False;
Propertiesbtn.Enabled:=False;
Disablebtn.Enabled:=False;
StatusBarStartUp.simpletext:='';
end;
end;
procedure TForm1.delbtnClick(Sender: TObject);
var RootKey:HKEY;
begin
if (Assigned(BootList.Selected)) and ((Sender<>delbtn) or (MessageBox(Handle,pchar('你确定要删除的启动项目"'+BootList.Selected.Caption+'"吗?'),'确认',MB_OKcancel+MB_ICONQUESTION)=1)) then
begin
if (Not SameText(Copy(BootList.Selected.SubItems[1],0,5),'HKEY_')) then
begin
if (Not DelStartUpFile(pchar(format('%s\%s',[BootList.Selected.SubItems[1], BootList.Selected.Caption])))) then showmessage('删除文件未成功,请检查文件路径及访问权限后再试。');
end else
begin
if Copy(BootList.Selected.SubItems[1],0,Pos('\',BootList.Selected.SubItems[1])-1)='HKEY_LOCAL_MACHINE' then RootKEY:=HKEY_LOCAL_MACHINE else RootKEY:=HKEY_CURRENT_USER;
if (Not DelStartUpRegKey(RootKEY,Copy(BootList.Selected.SubItems[1],Pos('\',BootList.Selected.SubItems[1]),Length(BootList.Selected.SubItems[1])), BootList.Selected.Caption)) Then showmessage('删除键值未成功,请检查注册表路径及访问权限后再试。');
end;
end;
FlatTitlebarBotton.Caption:='已删除所选程序';
BootListResize(Sender); //刷新列表显示
end;
procedure TForm1.DisablebtnClick(Sender: TObject);
var
RootKey:HKEY;
begin
try
if Copy(BootList.Selected.SubItems[1],0,Pos('\',BootList.Selected.SubItems[1])-1)='HKEY_LOCAL_MACHINE' then RootKEY:=HKEY_LOCAL_MACHINE else RootKEY:=HKEY_CURRENT_USER;
if BootList.Selected.SubItems[1][Length(BootList.Selected.SubItems[1])]='-' then
CreateStartUpRegKey(RootKey,(Copy(BootList.Selected.SubItems[1],Pos('\',BootList.Selected.SubItems[1]),Length(BootList.Selected.SubItems[1])-Pos('\',BootList.Selected.SubItems[1]))), BootList.Selected.Caption, BootList.Selected.SubItems[0])
else
CreateStartUpRegKey(RootKey,(Copy(BootList.Selected.SubItems[1],Pos('\',BootList.Selected.SubItems[1]),Length(BootList.Selected.SubItems[1]))+'-'), BootList.Selected.Caption, BootList.Selected.SubItems[0]);
DelStartUpRegKey(RootKEY,Copy(BootList.Selected.SubItems[1],Pos('\',BootList.Selected.SubItems[1]),Length(BootList.Selected.SubItems[1])), BootList.Selected.Caption);
except
showmessage('删除键值未成功,请检查注册表路径及访问权限后再试。');
end;
FlatTitlebarBotton.Caption:='已禁用此程序';
BootListResize(Sender); //刷新列表显示
end;
procedure TForm1.RunbtnClick(Sender: TObject);
begin
ShellExecute(Handle,'open',Pchar(Trim(BootList.Selected.SubItems[0])),'','',SW_SHOWNORMAL);
FlatTitlebarBotton.Caption:='运行程序';
end;
procedure TForm1.AddbtnClick(Sender: TObject);
begin
if (Sender=Addbtn) or (Assigned(BootList.Selected)) then
begin
if Sender=Addbtn then
begin
BootListSelectName:='';
BootListSelectCmd:='';
BootListSelectPath:='';
BootListSelectType:='';
end else
begin
BootListSelectName:=BootList.Selected.Caption;
BootListSelectCmd:=BootList.Selected.SubItems[0];
BootListSelectPath:=BootList.Selected.SubItems[1];
BootListSelectType:=BootList.Selected.SubItems[2];
end;
Application.CreateForm(TFormAttribute,FormAttribute);
FormAttribute.ShowModal;
end;
end;
///////////////////////系统自启动程序管理的所有过程结束,其中调用的主要过程在StartUpManger单元中//////////////
/////////////////////设置优化功能操作模块所有过程开始(所用到的注册表函数在Globals单元中)/////////////////////////////////
procedure TForm1.PageControlSysConfigChange(Sender: TObject);
begin
case PageControlSysConfig.ActivePageIndex of
0:begin
try
Screen.Cursor:=crAppStart;
Application.ProcessMessages;
FlatSpeedButtonSysInfoCancelClick(Sender);
FlatSpeedButtonIeInfoCancelClick(Sender);
FlatSpeedButtonSysLoginMessageRestoreClick(Sender);
finally
Screen.Cursor:=crDefault;
end;
end;
1:begin
try
Screen.Cursor:=crAppStart;
Application.ProcessMessages;
FlatSpeedButtonSysConfigCancelClick(Sender);
finally
Screen.Cursor:=crDefault;
end;
end;
2:begin
try
Screen.Cursor:=crAppStart;
Application.ProcessMessages;
FlatSpeedButtonSysRestrictCancelClick(Sender);
finally
Screen.Cursor:=crDefault;
end;
end;
3:begin
try
Screen.Cursor:=crAppStart;
Application.ProcessMessages;
FlatSpeedButtonIEActiveXExportClick(Sender);
finally
Screen.Cursor:=crDefault;
end;
end;
end;
end;
procedure TForm1.FlatEditCashDirClick(Sender: TObject);
var Dir:string;
begin
Dir:=TFlatEdit(Sender).Text;
if SelectDirectory('目录选择...','',Dir) then TFlatEdit(Sender).Text:=Dir;
end;
procedure TForm1.FlatSpeedButtonSysConfigCancelClick(Sender: TObject);
begin //获得安全与性能
try
if GetRegIntegerKey(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\PriorityControl', 'Win32PrioritySeparation')=38 then CPUMuchTimeToProgram.Checked:=True else CPUMuchTimeToProgram.Checked:=False; //CPU较多时间运行应用程序
SytemAutoReboot.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\CrashControl', 'AutoReboot')); //当系统出错时自动重启
if GetRegStringKey(HKEY_CURRENT_USER, 'Control Panel\Desktop', 'WaitToKillAppTimeout')='1000' then ShortToCtrlAltDelTime.Checked:=True else ShortToCtrlAltDelTime.Checked:=False; //缩短Ctrl+Alt+Del响应时间(缩短出错应用程序响应时间)
AutoToEndProgram.Checked :=IntegerToBoolean(GetRegIntegerKey(HKEY_CURRENT_USER, 'Control Panel\Desktop','AutoEndTasks')); //自动中止无响应的程序
ClearPageFileAtShutdown.Checked:=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management','ClearPageFileAtShutdown')); //系统关闭时自动清理页面文件
ActiveLargeSystemCache.Checked:=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management','LargeSystemCache')); //启用服务器的大系统缓存
DisablePagingExecutive.Checked:=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management','DisablePagingExecutive')); //禁用使用系统页面文件
CloseMenuAnimate.Checked :=Not StringToBoolean(GetRegStringKey(HKEY_CURRENT_USER, 'Control Panel\Desktop\WindowMetrics','MinAnimate')); //关闭菜单的动画效果
CloseScrollAnimate.Checked :=Not integerToBoolean(GetRegintegerKey(HKEY_CURRENT_USER, 'Control Panel\Desktop','SmoothScroll')); //关闭菜单平滑滚动效果
WindowsUpDateMode.Checked :=Not integerToBoolean(GetRegBinaryKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Update','UpDateMode')); //加快Windows的刷新率
CloseStartMenuBanner.Checked :=integerToBoolean(GetRegBinaryKey(HKEY_CURRENT_USER,'Software\Microsoft\Windows\CurrentVersion\Policies\Explorer','NoStartBanner')); //关闭开始菜单动画效果
CloseWindowMenuAnimate.Checked:=not StringToBoolean(GetRegStringKey(HKEY_CURRENT_USER,'Control Panel\Desktop','DragFullWindows')); //关闭菜单窗口的视觉效果
DesktopProcess.Checked :=integerToBoolean(GetRegintegerKey(HKEY_CURRENT_USER,'Software\Microsoft\Windows\CurrentVersion\Explorer','DesktopProcess')); //设置桌面和Explorer独立进程
if GetRegStringKey(HKEY_CURRENT_USER,'Control Panel\Desktop','MenuShowDelay')='1' then MenuShowDelay.Checked:=True else MenuShowDelay.Checked:=False; //加快菜单显示响应程度
AlwaysUnloadDLL.Checked :=StringToBoolean(GetRegStringKey(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer','AlwaysUnloadDLL')); //自动从内存移除不使用的DLL
CloseDebugFun.Checked :=not StringToBoolean(GetRegStringKey(HKEY_LOCAL_MACHINE ,'SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug','Auto')); //关闭系统的自动调试功能
ContigFileAllocSize.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\FileSystem','ContigFileAllocSize')); //优化文件和多媒体应用程序
EnableUDMA66.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318}\0000','EnableUDMA66')); //启用IDE硬盘的UDMA66传输模式
NtfsDisableLastUpdate.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\FileSystem','NtfsDisableLastAccessUpdate')); //优化NTFS系统性能
NtfsDisableOldFileName.Checked:=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\FileSystem','NtfsDisable8dot3NameCreation')); //禁止NTFS的DOS兼容8.3文件名
RandomAdapter.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\NetBT\Parameters','RandomAdapter')); //启动Win2K多网卡自动平衡
Tcp1323Opts.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters','Tcp1323Opts')); //优化Tcp1323Opts
restrictanonymous.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Lsa','restrictanonymous')); //禁止匿名用户向2K建空连接
AutoShareServer.Checked :=Not integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\lanmanserver\parameters','AutoShareServer'));//禁止启用管理共享
AutoShareServer.Checked :=Not integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\lanmanserver\parameters','AutoSharewks')); //禁止启用服务器共享
ClearRecentDocsOnExit.Checked :=integerToBoolean(GetRegintegerKey(HKEY_CURRENT_USER,'Software\Microsoft\Windows\CurrentVersion\Policies\Explorer','ClearRecentDocsOnExit')); //每次系统注销时清除文档记录
if GetRegStringKey(HKEY_CLASSES_ROOT,'Folder\shell\DOS\command','')='cmd.exe /K CD %1' then FlatCheckBoxAddDosQuick.Checked:=True else FlatCheckBoxAddDosQuick.Checked:=False; //添加右键"DOS快速通道"
if RegValueExists(HKEY_CLASSES_ROOT,'lnkfile','IsShortCut') then DisableShutIco.Checked:=False else DisableShutIco.Checked:=True; //去除快捷方式小箭头
dontdisplaylastusername.Checked:=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system','dontdisplaylastusername')); //禁止显示上次登陆的用户名
FastReboot.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Shutdown','FastReboot')); //使用快速关机功能(Win98)
SystemStartOptions.Checked :=AnsiSameText(GetRegStringKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control','SystemStartOptions'),'NODETECT'); //启动快速启动功能(Win2K)
HiddenComputerName.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\lanmanserver\parameters','Hidden')); //在网络邻居里隐藏主机名
EnableICMPRedirect.Checked :=not integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters','EnableICMPRedirect')); //使系统抵抗一定的DDOS攻击(还有几个其它键值)
if (RegValueExists(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\NetBT\Parameters','SMBDeviceEnabled'))and(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\NetBT\Parameters','SMBDeviceEnabled')=0) then SMBDeviceEnabled.Checked:=True else SMBDeviceEnabled.Checked:=False; //关闭系统的445端口
RestrictGuestAccess.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\Eventlog\Application','RestrictGuestAccess')); //禁止Guest用户访问系统应用程序日志
RestrictGuestAccess.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\Eventlog\System','RestrictGuestAccess')); //禁止Guest用户访问系统日志
RestrictGuestAccess.Checked :=integerToBoolean(GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\Eventlog\Security','RestrictGuestAccess')); //禁止Guest用户访问系统安全日志
if GetRegintegerKey(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\LmHosts','Start')=4 then CloseNetBIOS.Checked:=True else CloseNetBIOS.Checked:=False; //关闭系统NetBIOS服务
if GetReginteger
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -