var
 hCurrentWindow:HWND;
 szText:array [0..254] of char;
begin
 hCurrentWindow := GetWindow (Handle ,GW_HWNDFIRST);
  if GetWindowText (hCurrentWindow ,@szText,255) >0 then
  ListBox1.Items.Add (inttostr(hCurrentWindow));
 while hCurrentWindow <> 0 do
 begin
 if GetWindowText (hCurrentWindow ,@szText,255) >0 then
  ListBox1.Items.Add (inttostr(hCurrentWindow));
 hCurrentWindow := GetWindow (hCurrentWindow ,GW_HWNDNEXT);
 end;
 end;

解决方案 »

  1.   

    可以使用delphi自带的小工具:winsight32;
    可以获得打开程序窗体名,及其句柄等
      

  2.   

    这个方法得到了系统所有进程的ID和名称。我是想知道,像在2000下的任务管理器那样,能够得到正在运行的应用程序的名称及Handle。
      

  3.   

    结果显示了系统中正在运行的所有主窗口,其中大部分是隐藏的
    type
      EnumWindowsProc = function (Hwnd: THandle;
        Param: Pointer): Boolean; stdcall;function GetTitle (Hwnd: THandle; Param: Pointer): Boolean; stdcall;
    var
      Text: string;
    begin
      SetLength (Text, 100);
      GetWindowText (Hwnd, PChar (Text), 100);
      FormCallBack.ListBox1.Items.Add (
        IntToStr (Hwnd) + ': ' + Text);
      Result := True;
    end;procedure TFormCallback.BtnTitlesClick(Sender: TObject);
    var
      EWProc: EnumWindowsProc;
    begin
      ListBox1.Items.Clear;
      EWProc := GetTitle;
      EnumWindows (@EWProc, 0);
    end;
      

  4.   

    var
     hCurrentWindow:HWND;
     szText:array [0..254] of char;
    begin
     hCurrentWindow := GetWindow (Handle ,GW_HWNDFIRST);
      if GetWindowText (hCurrentWindow ,@szText,255) >0 then
      ListBox1.Items.Add (inttostr(hCurrentWindow)+':'+strpas(@szText));
     while hCurrentWindow <> 0 do
     begin
     if GetWindowText (hCurrentWindow ,@szText,255) >0 then
      ListBox1.Items.Add (inttostr(hCurrentWindow)+':'+strpas(@szText));
     hCurrentWindow := GetWindow (hCurrentWindow ,GW_HWNDNEXT);
     end;
     end;
      

  5.   

    用EnumProcesses,EnumProcessModules,OpenProcess,GetModuleBaseName这几个函数就可以得到了
      

  6.   

    大侠,有没有例子呢。 还有
    netlib(河外孤星) :你的那个例子是得到系统里所有运行的进程了吧。
      

  7.   

    有个测试程序,要吗?在win2000下可以,98下没有测试过
      

  8.   

    好极。[email protected] 给分。