是控件的名称,即组件名,不是标题。SendMessage 好像没有相应的消息。
解决方案 »
- 关于程序员笔记本的问题
- 关于统计 表 一个字段 中连续出现相同数据的一个算法
- 初学求助!
- 用dbExpress连接SQL Server数据库时,连接不上?
- 请问哪里有Install Shield 工具下载???
- 求MediaPlayer的EnabledButtons属性的代码格式
- 如何将这段代码写为控件来使用,谢谢...
- 怎么看 .dll文件?
- 公式编辑器(我本想出100分,为何最多只能填20? Why??????????????????????)
- delphi语法---packed record
- 使用PostMessage后台发送模拟按键的问题
- 请教一下,idhttp怎样取到网页js动态生成的内容
EnumChildWindows
需要引用 PSAPI单元
//可以获取D7...D2010任何版本的编译后的程序,其他版本有待考证,
//本过程在D7...D2010编译使用没发现异常
//For Win32 , XP , Vista , Win7
Function GetDelphiWinControlProp_Name(HProcess , TID , H : THandle; var Name : String) : Boolean; overload;
var
D , Module , PID : DWORD;
Msg : DWORD;
MsgName : String;
Addr : Pointer;
begin
Result := False;
Module := 0;
if (not EnumProcessModules(HProcess , @Module , 4 , D)) or (Module=0) then exit;
MsgName := Format('ControlOfs%.8X%.8X', [Module, TID]);
MSG := RegisterWindowMessage(Pointer(MsgName));
Addr := Pointer(SendMessage(H, Msg, 0, 0));
if Addr=NIL then exit;
PID := 8;//PID := GetDelphiOneVersionComponentPropPos;
if Integer(PID)<=4 then exit;
if not ReadProcessMemory(HProcess ,
Ptr(DWORD(Addr) + PID),
@TID ,
4,
D) then exit;
if not ReadProcessMemory(HProcess ,
Ptr(TID - 4),
@PID ,
4,
D) then exit;
//假设控件的名称最大长度200,这个值 值得商榷
if (Integer(PID)<=0) or (Integer(PID)>200) then exit;
MSG := 0;
if not ReadProcessMemory(HProcess ,
Ptr(TID),
@Msg ,
2,
D) then exit;
if MSG and $FF00 =0 then PID := PID * 2;
GetMem(Addr , PID+2);
ZeroMemory(Addr , PID+2);
if not ReadProcessMemory(HProcess ,
Ptr(TID),
Addr ,
PID,
D) then begin FreeMem(Addr); exit; end;
if MSG and $FF00 = 0 then
Name := PWideChar(Addr)
else
Name := PAnsiChar(Addr);
Result := True;
end;//可以获取D7...D2010任何版本的编译后的程序,其他版本有待考证,
//本过程实用于D7...D2010版本
//For Win32 , XP , Vista , Win7
Function GetDelphiWinControlProp_Name(H : THandle; var Name : String) : Boolean;overload;
var
PID , TID : DWORD;
HProcess : THandle;
begin
Result := False;
TID := GetWindowThreadProcessID(H, PID);
if (TID=0) or (PID=0) then exit;
HProcess := OpenProcess(PROCESS_VM_READ or PROCESS_QUERY_INFORMATION , False , PID);
if HProcess<>0 then begin
Result := GetDelphiWinControlProp_Name(HProcess , TID , H , Name);
CloseHandle(HProcess);
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
S : String;
H : THandle;
begin
H := Windows.FindWindow(NIL , 'xxxxxx');
if H<>0 then begin
GetDelphiWinControlProp_Name(Handle , S);
Caption := Caption + ' ' + S;
end;
end;
FreeMem(Addr); //哎,人越来越老了,这句要加上
Result := True;
(蓝色光芒) 太复杂了,我什么时候才可以达到这个境界~~~~~~~` -_-#