function EnumChildProc(AHWnd: HWnd; lParam: lParam): Boolean; stdcall;<br>var<br> aryWndCaption: array[0..255] of Char;<br> aryWndClassName: array[0..255] of Char;<br> sClassName: string;<br>begin<br> FillChar(aryWndCaption, 256, #0);<br> FillChar(aryWndClassName, 256, #0);<br> GetWindowText(AHWnd, aryWndCaption, 255);<br> GetClassName(AHWnd, aryWndClassName, 255);<br> sClassName := StrPas(aryWndClassName);<br><br> if AnsiCompareText(sClassName, 'SysListView32') = 0 then<br> begin<br> frmMain.Label1.Caption := IntToHex(AHWnd, 8);<br> //frmMain.Label2.Caption := StrPas(aryWndCaption);<br> end;<br><br> Result := True;<br>end;<br><br>function EnumWindowProc(AHwnd: HWnd; lparam: lParam): Boolean; stdcall;<br>var<br> aryWndCaption: array[0..255] of Char;<br> aryWndClassName: array[0..255] of Char;<br> sClassName: string;<br>begin<br> FillChar(aryWndCaption, 256, #0);<br> FillChar(aryWndClassName, 256, #0);<br> GetWindowText(AHWnd, aryWndCaption, 255);<br> GetClassName(AHWnd, aryWndClassName, 255);<br> sClassName := StrPas(aryWndClassName);<br> if (AnsiCompareText(sClassName, 'Progman') = 0) or<br> (AnsiCompareText(sClassName, 'WorkerW') = 0) then<br> EnumChildWindows(AHWnd, @EnumChildProc, 0);<br> Result := True;<br>end;<br><br>{$R *.DFM}<br><br>procedure TfrmMain.btnSearchClick(Sender: TObject);<br>begin<br> EnumWindows(@EnumWindowProc, 0);<br>end;<br>偶这段代码是为了搜索一个特定的窗口,你看着改一下就OK了