delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
请教如何获得类似于“任务管理器”中“应用程序”面板下的程序标题?? Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiAPI/html/delphi_20061122142354184.html
如题,请各位帮帮忙~~~~  
  请注意不是进程列表,是应用程序标题列表:)

用WMI轻松搞定

 
  procedure   TForm1.FormCreate(Sender:   TObject);  
  begin  
      WList   :=   TObjectList.Create;  
  end;  
   
  procedure   TForm1.FormDestroy(Sender:   TObject);  
  begin  
      WList.Free;  
  end;  
   
  function   EnumWindowProc(Handle:   HWND;   LParam:   Longint):   BOOL;   stdcall;  
  var  
      Info:   TWindowInfo;  
      s:   string;  
  begin  
      Info   :=   TWindowInfo.Create;  
      Info.Handle   :=   Handle;  
      SetLength(s,   256);  
      GetWindowText(Handle,   PChar(s),   256);  
      Info.Name   :=   s;  
      Info.DispStr   :=   'Handle:   '   +   IntToHex(Handle,   8)   +   ',   Text:   '   +   s;  
      TList(LParam).Add(Info);  
      Result   :=   True;  
  end;  
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
  var  
      i:   Integer;  
  begin  
      WList.Clear;  
      EnumWindows(@EnumWindowProc,   Integer(WList));  
      ListBox1.Clear;  
      for   I   :=   0   to   WList.Count   -   1   do  
          ListBox1.Items.Add(TWindowInfo(WList[I]).DispStr);  
  end;  
 

同意楼上  
 

呵呵,各位同志们,有那么简易全面好使的WMI你们怎么都不动容啊。

TO   maozefa(阿发伯):  
  程序无法运行,提示Undeclared   identifier:   'TObjectList'  
  而且TWindowInfo只是一个结构体而已阿,没有.create这个构造函数啊~~~  
  帮忙~~~  
  谢了先~~~

uses  
      Contnrs;  
   
      TWindowInfo   =   class  
      public  
          Handle:   HWND;  
          Name:   string;  
          DispStr:   string;  
      end;  
 

WList:   TList;

to   maozefa(阿发伯):  
  呵呵,现在程序可以执行了,但不是我要的效果,有一些没有用处的名称。我想要的就是在任务管理器中显示出来的那些,呵呵,帮帮忙~~~~~再看看~~~~~  
  //**********************//  
  Windows   任务管理器  
  自动下拉  
  CodeParamWindow  
  CodeParamWindow  
  金山词霸   2006(暂停取词)  
  SysFader  
  SysFader  
  SysFader  
  SysFader  
  Shabout  
  Delphi   7  
  请教如何获得类似于“任务管理器”中“应用程序”面板下的程序标题??   -   Windows   Internet   Explorer  
  Delphi   7  
  Delphi   7  
  SendMessage   -   Microsoft   Visual   C++   -   [sc.c]  
  Microsoft   Spy++   -   [Windows   4]  
  无标题   -   记事本  
  KibitzWindow  
  DBK  
  MCI   command   handling   window  
  杂项  
  ActiveMovie   Window  
  ddd  
  Acrobat   IEHelper  
  DDE   Server   Window  
  Acrobat   IEHelper  
  DBK  
  Acrobat   IEHelper  
  压缩包  
  MCI   command   handling   window  
  MCI   command   handling   window  
  DDE   Server   Window  
  GDI+   Window  
  Delphi  
  C:\WINDOWS\system32\cmd.exe  
  Acrobat   IEHelper  
  SysFader  
  CodeParamWindow  
  MCI   command   handling   window  
  Acrobat   IEHelper  
  迅雷5  
  MCI   command   handling   window  
  DBK  
  SysFader  
  DDE   Server   Window  
  电表  
  Acrobat   IEHelper  
  MCI   command   handling   window  
  MCI   command   handling   window  
  Connections   Tray  
  MS_WebcheckMonitor  
  MediaCenter  
  NVSVCPMMWindowClass  
  SysFader  
  Program   Manager  
  //**********************//

http://community.csdn.net/Expert/topic/4742/4742530.xml?temp=.8409998

大家帮忙看看~~~~

to   sanmaotuo(老冯):  
  呵呵,没听过WMI啊,是什么东东?详细说一下呗~~~~

to   liangqingzhi(老之):   谢谢了,解决,顺便问一下,Style:=   GetWindowLong(aHWnd,   GWL_STYLE);   中Style的值都包括什么啊(类似于WS_POPUP之类)?候教中~~~~

没有WMI没有关系,你这样处理。包你满意  
   
  var  
      _Tasks:   Tasks;  
      Enum:   IEnumVARIANT;  
      NumElements:   ULong;  
      _Task:   OleVariant;  
  begin  
  _Tasks   :=   WordApplication.Tasks;  
  Enum   :=   _Tasks._NewEnum   as   IEnumVARIANT;  
  while   Succeeded(Enum.Next(1,   _Task,   NumElements))   and   (NumElements   >   0)   do  
  begin  
      if   (IUnknown(_Task)   as   Task).Visible   then  
      ShowMessage((IUnknown(_Task)   as   Task).Name);  
  end;

最佳路径哈。

老水你试试我这个,好轻松哟。


文章来源:http://www.delphi2007.net/DelphiAPI/html/delphi_20061122142354184.html
posted on 2008-11-27 21:11 delphi2007 阅读(255) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。