//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString str;
String buf[100];
int n=0;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//EnumWindowsList(hwnd, (LPARAM)3);
}
//---------------------------------------------------------------------------
bool CALLBACK LPWinProc(HWND hwnd)
{
char caption[255];
GetWindowText(hwnd, caption,255);
buf[n++] = caption;
return true;
}
bool CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lparam)
{
TMemo* memo = (TMemo*) lparam;
char buffer[256];
GetClassName(hwnd,buffer,255);
AnsiString ClassName=AnsiString(buffer);
SendMessage(hwnd,WM_GETTEXT,(WPARAM)255,(LPARAM)buffer);
AnsiString WindowText=AnsiString(buffer);
if(WindowText.Pos(str)!=0)
{
memo->Lines->Add("HWND:"+IntToHex((int)hwnd,8));
memo->Lines->Add(WindowText);
memo->Lines->Add(ClassName);
return false;
}
return true;
}
/*void EnumWindowsList(HWND hwnd,LPARAM lparam)
{
TMemo* memo = (TMemo*) lparam;
char caption[256];
char *s[100];
int n=0,i=0;
GetWindowText(hwnd,caption,255);
s[n++] = caption;
while( WindowText.Pos(str)!=0 )
{
memo->Lines->Add(WindowText);
memo->Lines->Add(ClassName);
}
} */
void __fastcall TForm1::Button2Click(TObject *Sender)
{
MemoWindow->Lines->Clear();
MemoList->Clear();
str=Edit3->Text;
EnumWindows((WNDENUMPROC)EnumWindowsProc,(LPARAM)MemoWindow);
//EnumWindows((WNDENUMPROC)EnumWindowsProc,(LPARAM)MemoList);
}
//---------------------------------------------------------------------------