Delphi编程实现显示桌面功能

//兼容win7 vista xp 的桌面嵌入代码(delphi) 
procedure findDesktopWnd;
  Function MyEnumWindowProc(wnd: HWND; LPARAM: LPARAM): Boolean; stdcall;
  var
  sndWnd, targetWnd: Cardinal;
  begin
  sndWnd := FindWindowEx(wnd, 0, 'SHELLDLL_DefView', 0);
  if sndWnd = 0 then
  begin
  Result := true;
  Exit;
  end;
  targetWnd := FindWindowEx(sndWnd, 0, 'SysListView32', 'FolderView');
  if targetWnd = 0 then
  begin
  Result := true;
  Exit;
  end;
  deskTopHandel := wnd;
  Result := false;
  end;

begin
  EnumWindows(@MyEnumWindowProc, 0);
end;


 

uses   shellapi; 

ShellExecute(handle,   nil,   'c:\windows\...\Internet   Explorer\Quick   Launch\显示桌面.scf ',   nil,   nil,   sw_shownormal);


 

最简单的:PostMessage(HWND_BROADCAST,   WM_SYSCOMMAND,   SC_MINIMIZE,   0);

 

//同时按下WINDOW键和M键能最小化所有窗口   91   window   key   77   M  
    keybd_event(91,   0,   0,   0);
    keybd_event(77,   0,   0,   0);
    keybd_event(77,   0,   KEYEVENTF_KEYUP,   0);
    keybd_event(91,   0,   KEYEVENTF_KEYUP,   0);

 

其实正宗的解决方法是发送一个TaggleDesktop的DDE消息给Explorer.exe。

 

抄袭自:

http://topic.csdn.net/t/20010417/23/99323.html


var
  vShellApplication: OleVariant;
begin
  vShellApplication := CreateOleObject('Shell.Application');
  vShellApplication.ToggleDesktop;
end;


你可能感兴趣的:(Delphi)