【例子介绍】
通过该程序可以获取Delphi编程开发的窗口控件类及控件名称,并实现对ADO的连接解析
【相关图片】
【源码结构】
function MyFindControl(Handle: HWnd): TWincontrol;
var
OwningProcess: DWORD;
begin
Result:= nil;
GetWindowThreadProcessID(Handle, OwningProcess);
ShowMessage(IntToStr(OwningProcess) ' , ' IntToStr(GetCurrentProcessID));
if (Handle <> 0)and(OwningProcess <> 0)and
(OwningProcess = GetCurrentProcessID) then
begin
ShowMessage(IntToStr(GetProp(Handle, MakeIntAtom(ControlAtom))));
if GlobalFindAtom(PChar(ControlAtomstring)) = ControlAtom then
begin
Result:= Pointer(GetProp(Handle, MakeIntAtom(ControlAtom)));
end
else
begin
Result:= Pointer(SendMessage(Handle, RM_GetObjectInstance, 0, 0));
end;
end;
end; { MYFindControl }
function GetAllHandle(AhWnd: Integer; lparam: Longint): Boolean; stdcall;
var
WndClassName: Array[0..255] of WideChar; //[0..254]
WndCaption: Array[0..255] of WideChar; //[0..254]
begin
Result:= True;
GetClassName(AhWnd, @WndClassName, 256);
GetWindowText(AhWnd, WndCaption, 256);
SetLength(frmClass, Length(frmClass) 1);
frmClass[High(frmClass)].Handle:= AhWnd;
frmClass[High(frmClass)].Name:= StrPas(WndClassName);
frmClass[High(frmClass)].Title:= StrPas(WndCaption);
end;
评论