program APIHide;

uses
  windows, mmsystem;

//{$R *.RES}
const
  id_hide = 101;
  id_show = 102;
  id_exit = 103;
var
  Instance: HWnd;
  WindowClass: TWndClass;
  Handle: HWnd;
  msg: TMsg;
  h, d: HWND;

procedure DoExit;
begin
  UnRegisterHotKey(Handle, id_hide);
  UnRegisterHotKey(Handle, id_show);
  UnRegisterHotKey(Handle, id_exit);
  Halt;
end;

function WindowProc(Hwn, msg, wpr, lpr: longint): longint; stdcall;
begin
  result := defwindowproc(hwn, msg, wpr, lpr);
  if msg = wm_destroy then
    DoExit;
//---------------------------------------------------------
  if msg = WM_HOTKEY then
    if wpr = id_hide then
    begin
      d := FindWindow('Progman', nil);
      ShowWindow(d, SW_HIDE);
      h := FindWindow('Shell_TrayWnd', nil);
      ShowWindow(h, SW_HIDE);
    end
    else
      if wpr = id_exit then
      begin
        ShowWindow(d, SW_SHOW);
        ShowWindow(h, SW_SHOW);
        DoExit
      end
      else
      begin
        ShowWindow(d, SW_SHOW);
        ShowWindow(h, SW_SHOW);
      end;

//----------------------------------------------------
//  if msg = wm_KeyDown then
//    if wpr = VK_ESCAPE then
//      DoExit;
//----------------------------------------------------
end;
/////////////////////// начинается прога отсюда/////////////////////
begin
  instance := GetModuleHandle(nil);

  WindowClass.style := CS_HRedraw or CS_VRedraw;
  WindowClass.Lpfnwndproc := @windowproc;
  WindowClass.Hinstance := Instance;
  WindowClass.HbrBackground := color_btnface;
  WindowClass.LpszClassName := 'DX';
//WindowClass.Hcursor:=LoadCursor(0,IDC_ARROW);

  RegisterClass(WindowClass);

  Handle := CreateWindowEx(0, 'DX', '', ws_overlappedwindow, 1, 1, 200, 200, 0, 0, Instance, nil);

//ShowWindow(Handle,SW_SHOW);
  //UpdateWindow(Handle);

  RegisterHotKey(Handle, id_hide, 0 {MOD_SHIFT}, VK_F8);
  RegisterHotKey(Handle, id_show, 0, VK_F9);
  RegisterHotKey(Handle, id_exit, 0, VK_F10);

  while (GetMessage(msg, 0, 0, 0)) do
  begin
    translatemessage(msg);
    dispatchmessage(msg);
  end;
end.