hWnd2, hWnd1: integer;
//屏蔽任务栏
hWnd1 := FindWindow(‘Shell_TrayWnd’, nil);
ShowWindow(hWnd1, SW_HIDE);
//屏蔽桌面图标
hWnd2 := FindWindow(‘ProgMan’, nil);
ShowWindow(hWnd2, SW_HIDE);
//下面是屏蔽任务栏的各个部分
EnableWindow(FindWindowEx(hWnd1, 0, ‘Button’, nil), false);
hWnd2 := FindWindowEx(hWnd1, HWND(0), ‘Button’, nil); //得到开始按钮的窗口句柄
ShowWindow(hWnd2, SW_HIDE);
hWnd2 := FindWindowEx(hWnd1, HWND(0), ‘ReBarWindow32’, nil); //得到应用程序切换区的窗口句柄
ShowWindow(hWnd2, SW_HIDE);
hWnd2 := FindWindowEx(hWnd1, HWND(0), ‘TrayNotifyWnd’, nil); //得到任务栏通知区的窗口句柄
ShowWindow(hWnd2, SW_HIDE);
hWnd2 := FindWindowEx(hWnd1, HWND(0), ‘TrayNotifyWnd’, nil);
hWnd2 := FindWindowEx(hWnd2, HWND(0), ‘TrayCLockWClass’, nil); //得到任务栏时钟的窗口句柄
ShowWindow(hWnd2, SW_HIDE);
注意:
屏蔽任务栏后,但Win开始按钮仍旧显示,不能通过上面的方法屏蔽
解决办法是停止:Explorer.exe进程
iID := FindProcessName(‘Explorer.exe’);
if iID > 0 then CloseOneProcess(iID);
但这样关闭进程后,系统又会重新启动Explorer.exe,这有一个参数设置是否自动重启Explorer.exe:
reg.RootKey := HKEY_LOCAL_MACHINE;
if reg.OpenKey(‘SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon’, True) then
reg.WriteInteger(‘AutoRestartShell’, iSign);
iSign:0-不重启 1-自动重启
function FindProcessName(sName: string): DWORD;
var
lppe: tprocessentry32;
sshandle: thandle;
found: boolean;
begin
result := 0;
sshandle := createtoolhelp32snapshot(TH32CS_SNAPPROCESS, 0);
lppe.dwSize := Sizeof(lppe);
found := process32first(sshandle, lppe);
while found do
begin
if ansiCompareText(UpperCase(ExtractFileName(lppe.szExefile)), UpperCase(sName)) = 0 then
begin
result := lppe.th32ProcessID;
Break;
end;
found := process32next(sshandle, lppe); {检索下一个进程}
end;
CloseHandle(sshandle);
end;
function CloseOneProcess(ProcessID: DWORD): Boolean;
var
h: THandle;
begin
Result := False;
if ProcessID <> 0 then
begin
h := OpenProcess(PROCESS_TERMINATE, False, ProcessID);
if h = 0 then begin
//Application.MessageBox(‘无法读取该进程信息,终止进程失败’, ‘AAAAAA’,MB_OK);
Exit;
end;
TerminateProcess(h, 0);
//if not TerminateProcess(h, 0) then
//Application.MessageBox(PChar(‘无法终止进程:’ + IntToStr(ProcessID)), ‘AAAAAA’,MB_OK);
end;
Result := True;
end;
这篇博客介绍了如何使用编程方法来隐藏Windows的任务栏和桌面图标,并提供了详细步骤。通过FindWindow和ShowWindow函数实现任务栏和桌面图标的屏蔽,同时解决开始按钮仍然显示的问题,方法是结束Explorer.exe进程并修改注册表以阻止其自动重启。

2113

被折叠的 条评论
为什么被折叠?



