频道分类

Delphi 如何确定活动桌面是否已启用

作者:admin 来源: 日期:2020/11/11 14:59:48 人气: 标签:

 
Unit1;
 
 interface
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, StdCtrls;
 
 type
   TForm1 = class(TForm)
     Button1: TButton;
     procedure Button1Click(Sender: TObject);
   private
     { Private declarations }
   public
   function IsActiveDeskTopOn:Boolean;
     { Public declarations }
   end;
 
 var
   Form1: TForm1;
 
 implementation
 
 {$R *.dfm}
 function TForm1.IsActiveDeskTopOn:Boolean;
 var
   Hd: HWND;
 begin
   Result := False;
   Hd := FindWindow( Pchar('Progman'), nil);
   Hd := FindWindowEx( hd, 0, 'SHELLDLL_DefView', nil);
   Hd := FindWindowEx( hd, 0, 'Internet Explorer_Server', nil);
   if hd = 0 then
     Result := False
   else
     Result := True;
 end;

 procedure TForm1.Button1Click(Sender: TObject);
 begin
 if IsActiveDeskTopOn then
  showmessage('Active Desktop is ON')
 else
  showmessage('Active Desktop is OFF');
 end;
 
 end.