function FindWindowEx2(hParent: HWND; ChildClassName:
string; ChildNr: Word): HWND;
var
i: Word;
hChild: HWND;
begin
hChild := 0;
Result := 0;
Dec(ChildNr);
for i := 0
to ChildNr
do
begin
hChild := FindWindowEx(hParent, hChild, PChar(ChildClassName),
nil);
if hChild = 0
then
Break;
Result := hChild;
end;
end;
function GetWinText(aHandle: HWND):
string;
var
iBuffLen : Integer;
pBuffer : PChar;
begin
iBuffLen := SendMessage(aHandle, WM_GETTEXTLENGTH, 0, 0);
if iBuffLen > 0
then begin
Inc(iBuffLen);
GetMem(pBuffer, iBuffLen);
try
SendMessage(aHandle, WM_GETTEXT, iBuffLen, LPARAM(pBuffer));
Result := pBuffer;
finally
FreeMem(pBuffer);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
wndMain, wndChild: HWND;
begin
wndMain := FindWindow('
PPAppFrameClass','
Napster');
if wndMain <> 0
then
begin
wndChild := FindWindowEx(wndMain, 0, '
CUISplitterWindow',
nil);
wndChild := FindWindowEx(wndChild, 0, '
#32770',
nil);
wndChild := FindWindowEx(wndChild, 0, '
CUIHorSplitterWindow',
nil);
wndChild := FindWindowEx(wndChild, 0, '
#32770',
nil);
wndChild := FindWindowEx2(wndChild,'
Static', 6);
if wndChild <> 0
then
begin
ShowMessage(GetWinText(wndChild));
end;
end;
end;