1.
procedure hideTaskbar; //隐藏
var
wndHandle : THandle;
wndClass : array[0..50] of Char;
begin
StrPCopy(@wndClass[0], 'Shell_TrayWnd');
wndHandle := FindWindow(@wndClass[0], nil);
ShowWindow(wndHandle, SW_HIDE);
End;
procedure showTaskbar; //显示
var
wndHandle : THandle;
wndClass : array[0..50] of Char;
begin
StrPCopy(@wndClass[0], 'Shell_TrayWnd');
wndHandle := FindWindow(@wndClass[0], nil);
ShowWindow(wndHandle, SW_RESTORE);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, nil, 0); //屏蔽系统键
hidetaskbar;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0,nil, 0); //恢复系统键
showTaskbar;
end;
还有
在implementation后添加声明:
function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer; stdcall; external 'KERNEL32.DLL';
RegisterServiceProcess(GetCurrentProcessID, 1);//隐藏
RegisterServiceProcess(GetCurrentProcessID, 0);//显示
2.自己添加一个变量 CanCloseMyForm:Boolean;
在窗体的OnClose中加入:
if not CanCloseMyForm then
CanClose:=False;
自己关闭的过程为:
CanCloseMyForm:=True;
Self.Close;