请问怎样得到另外运行的软件里面label的caption的内容。因为他没有句柄该怎样得到 ( 积分: 100 )

  • 主题发起人 主题发起人 980
  • 开始时间 开始时间
9

980

Unregistered / Unconfirmed
GUEST, unregistred user!
请问怎样得到另外运行的软件里面label的caption的内容。因为他没有句柄该怎样得到
 
请问怎样得到另外运行的软件里面label的caption的内容。因为他没有句柄该怎样得到
 
参考http://www.delphibbs.com/keylife/iblog_show.asp?xid=12219
 
谢谢你,我看看。这里还有别的和这个相关的东西吗
 
用不到HOOK吧,直接findwindow ,findwindowex或者用minispy查一下,在来个sendmessage就OK了吧
 
楼上,你倒是SendMessage一下取Label.Caption内容试试,Label有句柄吗?你的Message发给谁呀?嘿嘿
 
可以先找到LABEL所在窗体的句柄,再根据Form1.components进行判断试试
 
delphi内的label没有handle(句柄),hook后
 
我知道的 使用句柄肯定不能实现的。
 
利用屏幕取词的原理
 
其实  “利用屏幕取词的原理  ” 实现起来不是特别的完美。但还不知道怎样做。谢谢楼上的各位了
 
library GetWord32;<br>uses<br> &nbsp;SysUtils,<br> &nbsp;Windows,<br> &nbsp;UnitHookDLL in 'UnitHookDLL.pas',<br> &nbsp;QTThunkU in 'QTThunkU.pas',<br> &nbsp;UnitHookType in 'UnitHookType.pas';<br><br>exports<br> &nbsp;OpenGetKeyHook,<br> &nbsp;CloseGetKeyHook;<br>begin<br>end.<br><br><br>unit UnitHookDLL;<br>interface<br>uses Windows, Messages, Dialogs, SysUtils, UnitHookType, Math;<br><br>type<br> &nbsp;THandle16 = Word;<br>function OpenGetKeyHook(sender: HWND; MessageID: WORD): BOOlean; stdcall;<br>function CloseGetKeyHook: BOOLean; stdcall;<br><br>var<br> &nbsp;pShMem: PShareMem;<br> &nbsp;hMappingFile: THandle;<br> &nbsp;FirstProcess: boolean;<br> &nbsp;pFuncCreate, pFuncFree, pFuncCheck: Pointer;<br> &nbsp;hInst16: THandle;<br> &nbsp;MessageHook: HHOOK;<br><br>{$STACKFRAMES On}<br>implementation<br><br>uses QTthunku;<br><br>{执行16位代码下进行取词,修改函数的入口}<br>function SetGDIHook: boolean; stdcall;<br>begin<br> &nbsp;result := false;<br> &nbsp;if pFuncCreate = nil then exit;<br> &nbsp;asm<br> &nbsp; &nbsp; &nbsp;pushad<br> &nbsp; &nbsp; &nbsp;push ebp<br> &nbsp; &nbsp; &nbsp;sub esp,$2c<br> &nbsp; &nbsp; &nbsp;mov edx, pFuncCreate {函数地址}<br> &nbsp; &nbsp; &nbsp;mov ebp,esp<br> &nbsp; &nbsp; &nbsp;add ebp,$2c<br> &nbsp; &nbsp; &nbsp;{利用Thunk执行16位下的函数,函数地址保存在edx中}<br> &nbsp; &nbsp; &nbsp;call &nbsp;QT_Thunk<br> &nbsp; &nbsp; &nbsp;add esp,$2c<br> &nbsp; &nbsp; &nbsp;pop ebp<br> &nbsp; &nbsp; &nbsp;mov byte ptr @result,al<br><br> &nbsp; &nbsp; &nbsp;popad<br> &nbsp;end;<br>end;<br><br>{执行16位代码下取消取词,恢复函数入口}<br><br>function UnSetGDIHook: boolean; stdcall;<br>begin<br> &nbsp;result := false;<br> &nbsp;if pFuncFree = nil then exit;<br> &nbsp;asm<br> &nbsp; &nbsp; {保寄存器的值}<br> &nbsp; &nbsp; &nbsp;pushad<br> &nbsp; &nbsp; &nbsp;push ebp<br> &nbsp; &nbsp; &nbsp;sub esp,$2c<br> &nbsp; &nbsp; &nbsp;mov edx, pFuncFree {函数地址}<br> &nbsp; &nbsp; &nbsp;mov ebp,esp<br> &nbsp; &nbsp; &nbsp;add ebp,$2c<br> &nbsp; &nbsp; &nbsp;{利用Thunk执行16位下的函数,函数地址保存在edx}<br> &nbsp; &nbsp; &nbsp;call &nbsp;QT_Thunk<br> &nbsp; &nbsp; &nbsp;add esp,$2c<br> &nbsp; &nbsp; &nbsp;pop ebp<br> &nbsp; &nbsp; &nbsp;mov byte ptr @result,al<br><br> &nbsp; &nbsp; &nbsp;popad<br> &nbsp;end;<br>end;<br><br>function CheckBuf: boolean; stdcall;<br>var<br> &nbsp;asd1, asd2: pchar;<br>begin<br> &nbsp;result := false;<br> &nbsp;if pFuncCheck = nil then exit;<br> &nbsp;{分配固定的内存,提供与16位代码交换数据}<br> &nbsp;asd1 := GlobalAllocPtr16(GPTR, MAXBUF);<br> &nbsp;{16位指针转换为32位指针}<br> &nbsp;asd2 := Ptr16To32(asd1);<br> &nbsp;asm<br> &nbsp; &nbsp; {保存寄存器的值}<br> &nbsp; &nbsp; &nbsp;pushad<br> &nbsp; &nbsp; &nbsp;push ebp<br> &nbsp; &nbsp; &nbsp;sub esp,$2c<br> &nbsp; &nbsp; &nbsp;push asd1 &nbsp;{第一个参数。最多支持两个参数}<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {第二个参数}<br> &nbsp; &nbsp; &nbsp;mov edx, pFuncCheck{函数地址}<br> &nbsp; &nbsp; &nbsp;mov ebp,esp<br> &nbsp; &nbsp; &nbsp;add ebp,$2c<br> &nbsp; &nbsp; &nbsp;call &nbsp;QT_Thunk<br> &nbsp; &nbsp; &nbsp;add esp,$2c<br> &nbsp; &nbsp; &nbsp;pop ebp<br> &nbsp; &nbsp; &nbsp;mov byte ptr @result,al<br><br> &nbsp; &nbsp; &nbsp;popad<br> &nbsp;end;<br> &nbsp;if result then<br> &nbsp;begin<br> &nbsp; &nbsp;{拷贝数据到共享内存中}<br> &nbsp; &nbsp;strlcopy(@pShMem^.Text, asd2, MAXBUF);<br> &nbsp;end;<br> &nbsp;{释放16位指针}<br> &nbsp;GlobalFreePtr16(asd1);<br>end;<br><br>procedure IterateThroughItems(WND:HWND;menu:Hmenu;p:TPoint;Level:integer);<br>var<br> &nbsp; i:integer;<br> &nbsp; info:TMenuItemInfo;<br> &nbsp; rec:TRect;<br>begin<br> &nbsp; for i:=0 to GetMenuItemCount(menu)-1 do<br> &nbsp; begin<br> &nbsp; &nbsp; &nbsp;fillchar(info,sizeof(info),0);<br> &nbsp; &nbsp; &nbsp;info.cbSize:=sizeof(info);<br> &nbsp; &nbsp; &nbsp;info.fMask:=MIIM_TYPE or MIIM_SUBMENU;<br> &nbsp; &nbsp; &nbsp;info.cch:=256;<br> &nbsp; &nbsp; &nbsp;getmem(info.dwTypeData,256);<br> &nbsp; &nbsp; &nbsp;GetMenuItemInfo(menu,i,true,info);<br> &nbsp; &nbsp; &nbsp;GetMenuItemRect(wnd,menu,i,rec);<br> &nbsp; &nbsp; &nbsp;if (rec.Left&amp;lt;=p.X)and(p.X&amp;lt;=rec.Right)and(rec.Top&amp;lt;=p.Y)and(p.Y&amp;lt;=rec.Bottom)then<br> &nbsp; &nbsp; &nbsp;if (info.cch&amp;lt;&amp;gt;0) then<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; strlcopy(pShMem^.Text,info.dwTypeData,min(info.cch,MAXBUF));<br> &nbsp; &nbsp; &nbsp; &nbsp; PostMessage(pShMem^.hMainWnd, WM_MOUSEPT, 2, 2);<br> &nbsp; &nbsp; &nbsp;end;<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;freemem(info.dwTypeData,256);<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;info.dwTypeData:=nil;<br> &nbsp; &nbsp; &nbsp;if info.hSubMenu&amp;lt;&amp;gt;0 then<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; IterateThroughItems(wnd,info.hSubMenu,p,Level+1);<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; end;<br>end;<br><br>procedure fOnTimer(theWnd: HWND; msg, idTimer: Cardinal; dwTime: DWORD); stdcall; //CallBack Type<br>var<br> &nbsp;InvalidRect: TRECT;<br> &nbsp;hwndPtIn: HWND;<br> &nbsp;buffer:array[0..255]of char;<br> &nbsp;menu:Hmenu;<br>begin<br> &nbsp;pShmem^.nTimePassed := pShmem^.nTimePassed + 1;<br> &nbsp;if pShmem^.nTimePassed = 10 then<br> &nbsp;begin<br> &nbsp; &nbsp;{获取当前鼠标点的窗口句柄}<br> &nbsp; &nbsp;hwndPtIn := WindowFromPoint(pshmem^.pMouse);<br> &nbsp; &nbsp;{屏幕坐标转换为客户区的坐标}<br> &nbsp; &nbsp;ScreenToClient(hwndPtIn, pshmem^.pMouse);<br> &nbsp; &nbsp;setGDIHook;<br> &nbsp; &nbsp;if(pshmem^.pMouse.x&amp;lt;0)or(pshmem^.pMouse.y&amp;lt;0) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; Getwindowtext(hwndPtIn,buffer,sizeof(buffer)-1);<br> &nbsp; &nbsp; &nbsp; Setwindowtext(hwndPtIn,buffer);<br> &nbsp; &nbsp; &nbsp; ClientToScreen(hwndPtIn, pshmem^.pMouse);<br> &nbsp; &nbsp; &nbsp; //MenuItemFromPoint(hwndPtIn,GetMenu(hwndPtIn),pshmem^.pMouse);<br> &nbsp; &nbsp; &nbsp; menu:=GetMenu(hwndPtIn);<br> &nbsp; &nbsp; &nbsp; IterateThroughItems(hwndPtIn,menu,pshmem^.pMouse,1);<br>// &nbsp; &nbsp; &nbsp; BringWindowToTop(hwndPtIn);<br>// &nbsp; &nbsp; &nbsp; DrawMenuBar(hwndPtIn);<br> &nbsp; &nbsp;end<br> &nbsp; &nbsp;else begin<br> &nbsp; &nbsp; &nbsp; InvalidRect.left := pshmem^.pMouse.x;<br> &nbsp; &nbsp; &nbsp; InvalidRect.top := pshmem^.pMouse.y;<br> &nbsp; &nbsp; &nbsp; InvalidRect.Right := pshmem^.pMouse.x + 1;<br> &nbsp; &nbsp; &nbsp; InvalidRect.Bottom := pshmem^.pMouse.y + 1;<br> &nbsp; &nbsp; &nbsp; {强迫重画此点}<br> &nbsp; &nbsp; &nbsp; InvalidateRect(hwndPtIn, @InvalidRect, false);<br> &nbsp; &nbsp;end;<br> &nbsp;end<br> &nbsp;else if pShmem^.nTimePassed &amp;gt;= 11 then<br> &nbsp;begin<br> &nbsp; &nbsp;{如果鼠标定留时间超过一定值,即显示数据}<br> &nbsp; &nbsp;pShmem^.nTimePassed := 11;<br> &nbsp; &nbsp;{调用检查缓冲区的数据}<br> &nbsp; &nbsp;if CheckBuf then &nbsp;<br> &nbsp; &nbsp; &nbsp;{消息值为2表示缓冲区有数据}<br> &nbsp; &nbsp; &nbsp;PostMessage(pShMem^.hMainWnd, WM_MOUSEPT, 2, 2);<br> &nbsp;end;<br>end;<br><br>function MouseHookProc(nCode: integer; wPar: WParam; lPar: LParam): lResult; stdcall;<br>var<br> &nbsp;pMouseInf: TMouseHookStruct;<br>begin<br> &nbsp;pShmem^.nTimePassed := 0;<br> &nbsp;UnSetGDIHook; {采用stdcall,所以它里面的变量可以随意}<br> &nbsp;if (nCode &amp;gt;= 0) and ((wPar=WM_MOUSEMOVE)or(wPar=WM_NCMouseMove)) then<br> &nbsp;begin<br> &nbsp; &nbsp;pMouseInf := (PMouseHookStruct(lPar))^;<br> &nbsp; &nbsp;if (pShMem^.pMouse.x &amp;lt;&amp;gt; pMouseInf.pt.x) or<br> &nbsp; &nbsp; &nbsp;(pShMem^.pMouse.y &amp;lt;&amp;gt; pMouseInf.pt.y) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;if nCode = HC_NOREMOVE then<br> &nbsp; &nbsp; &nbsp; &nbsp;pShMem^.fStrMouseQueue := 'Not removed from the queue'<br> &nbsp; &nbsp; &nbsp;else<br> &nbsp; &nbsp; &nbsp; &nbsp;pShMem^.fStrMouseQueue := 'Removed from the queue';<br> &nbsp; &nbsp; &nbsp;{鼠标所在的位置}<br> &nbsp; &nbsp; &nbsp;pShMem^.pMouse := pMouseInf.pt;<br> &nbsp; &nbsp; &nbsp;{鼠标所在的窗口句柄}<br> &nbsp; &nbsp; &nbsp;pShMem^.hHookWnd := pMouseInf.hwnd;<br> &nbsp; &nbsp; &nbsp;{发送鼠标位置消息}<br> &nbsp; &nbsp; &nbsp;PostMessage(pShMem^.hMainWnd, WM_MOUSEPT, 1, 1); {1表示是鼠标消息}<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;pShMem^.hHookWnd := pMouseInf.hwnd;<br> &nbsp;end;<br><br> &nbsp;Result := CallNextHookEx(MessageHook, nCode, wPar, lPar);<br>end;<br><br>function OpenGetKeyHook(sender: HWND; MessageID: WORD): BOOLean; stdcall;<br>begin<br> &nbsp;{设置定时器}<br> &nbsp;pShmem^.fTimerID := SetTimer(0, 0, 20, @fOnTimer);<br> &nbsp;{添加鼠标钩子}<br> &nbsp;MessageHook := SetWindowsHookEx(WH_MOUSE, MouseHookProc, HInstance, 0); ;<br> &nbsp;result := true;<br>end;<br><br>function CloseGetKeyHook: BOOLean; stdcall;<br>begin<br> &nbsp;{关闭定时器}<br> &nbsp;KillTimer(0, pShmem^.fTimerID);<br> &nbsp;{取消钩子}<br> &nbsp;UnhookWindowsHookEx(MessageHook);<br> &nbsp;{取消取词}<br> &nbsp;UnSetGDIHook;<br> &nbsp;result := true;<br>end;<br><br>initialization<br> &nbsp; &nbsp; &nbsp; &nbsp;{如果映射文件已经存在则打开}<br> &nbsp; &nbsp; &nbsp; &nbsp;hMappingFile := OpenFileMapping(FILE_MAP_WRITE, False, MappingFileName);<br> &nbsp; &nbsp; &nbsp; &nbsp;if hMappingFile = 0 then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{创建映射文件}<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hMappingFile := CreateFileMapping($FFFFFFFF,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PAGE_READWRITE, {页面为可读写}<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SizeOf(TShareMem),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PChar(MappingFileName));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FirstProcess := true;<br> &nbsp; &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp; &nbsp; &nbsp;else FirstProcess := false;<br> &nbsp; &nbsp; &nbsp; &nbsp;if hMappingFile &amp;lt;&amp;gt; 0 then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{句柄pShMem指向映射文件地址}<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pShMem := PShareMem(MapViewOfFile(hMappingFile,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FILE_MAP_WRITE,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if pShMem = nil then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CloseHandle(hMappingFile);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('不能建立共享内存!');<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;if FirstProcess then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageHook := 0;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;pFuncFree := nil;<br> &nbsp; &nbsp; &nbsp; &nbsp;pFuncCreate := nil;<br> &nbsp; &nbsp; &nbsp; &nbsp;pFuncCheck := nil;<br> &nbsp; &nbsp; &nbsp; &nbsp;pshmem^.nTimePassed := 0;<br> &nbsp; &nbsp; &nbsp; &nbsp;{载入16位DLL,必须用LoadLibrary16}<br> &nbsp; &nbsp; &nbsp; &nbsp;hInst16 := LoadLibrary16('GetWord.DLL');<br> &nbsp; &nbsp; &nbsp; &nbsp;{载入成功}<br> &nbsp; &nbsp; &nbsp; &nbsp;if hInst16 &amp;gt;= 32 then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{取函数或过程的地址}<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pFuncCreate := GetProcAddress16(hInst16, 'TextHookCreate');<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pFuncFree := GetProcAddress16(hInst16, 'TextHookFree');<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pFuncCheck := GetProcAddress16(hInst16, 'checkbuf');<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (pFuncCreate = nil) or (pFuncFree = nil) or (pFuncCheck = nil) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pFuncCreate := nil;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pFuncFree := nil;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pFuncCheck := nil;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp; &nbsp; &nbsp;else begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;showmessage('打开16位DLL错误');<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br>finalization<br> &nbsp; &nbsp; &nbsp; &nbsp;if hInst16 &amp;gt;= 32 then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FreeLibrary16(hInst16);<br> &nbsp; &nbsp; &nbsp; &nbsp;UnMapViewOfFile(pShMem);<br> &nbsp; &nbsp; &nbsp; &nbsp;CloseHandle(hMappingFile);<br><br>end.<br><br>unit UnitHookType;<br><br>interface<br><br>uses windows, messages;<br><br>const<br> &nbsp;MaxStringLen = 100;<br> &nbsp;MAXBUF = 100;<br> &nbsp;WM_MOUSEPT = WM_USER + 1138;<br> &nbsp;MappingFileName = 'Mapping File GetWord16';<br><br>type<br> &nbsp;PPointer = ^Pointer;<br> &nbsp;TShareMem = packed record<br> &nbsp; &nbsp;hMainWnd: HWND; {主应用窗口}<br> &nbsp; &nbsp;hHookWnd: HWND; {鼠标所在窗口}<br> &nbsp; &nbsp;pMouse: TPoint; {鼠标信息}<br> &nbsp; &nbsp;fStrMouseQueue: array[0..MaxStringLen] of Char; {鼠标信息串}<br> &nbsp; &nbsp;nTimePassed: integer; {鼠标暂停时间}<br> &nbsp; &nbsp;bCanSpyNow: Boolean; {开始取词}<br> &nbsp; &nbsp;{钩子函数句柄}<br> &nbsp; &nbsp;Text: array[0..MAXBUF] of Char; {返回所取的字符串}<br> &nbsp; &nbsp;fTimerID: Cardinal;<br> &nbsp;end;<br> &nbsp;PShareMem = ^TShareMem;<br><br>implementation<br><br>end.<br><br><br><br>
 
屏幕取词?楼上贴的是Win98下32位Mouse Hook部分的DLL,还需要16位的取词DLL,再加上WinNT/2000/XP的取词方式还不一样,又需要一个DLL,要根据运行系统的不同加载不同的取词DLL,而且每次要取Label的内容时都要鼠标移到Label上面才可以取,基本上不具备实用性。<br>楼主,http://www.delphibbs.com/keylife/iblog_show.asp?xid=12219 提供的内容不能解决问题吗?原理相同的,找到Label所在Form的Handle,根据这个Handle获得Form的实例对象,再Form.Components遍历,不就可以啦?
 
http://www.delphibbs.com/keylife/iblog_show.asp?xid=12219 <br>这个帖子我看了,对我有点难度,我在参看,看人家的评论可以取出label的内容。我试试<br>谢谢各位帮忙了
 
你的代码没有注释 &nbsp;看起来更难了
 
根据Form.Components找label是个好方法,form.Handle可以用findwindow取得,由于不同进程,不能取得form/application/screen的指针?<br>
 
请问 &nbsp;lichengbin, &nbsp;<br>// DestMain := FindWindow('TFrm_Main', '客户信息资料');<br> // DestWnd := FindWindowEx(DestMain, 0, 'TDBGrid', nil);<br><br>这个可以得到TDBGrid的handle,但是一点击 &nbsp;“Cell[X,Y]”这个按钮就出错误提示<br> &nbsp; DestMain := FindWindow('TForm1', 'Form1');<br> &nbsp;DestWnd := FindWindowEx(DestMain, 0, 'TLabel', nil);<br><br>这个呢DestWnd 的值始终为0
 
老兄,也不看看我的示例程序是Hook什么组件的吗?Hook StringGrid的,HookSG.dll中的MsgWndProc中的SG变量类型是TStringGrid,你没看见吗?DBGrid是从TCustomGrid继承来的,可不是TStringGrid的子类呀。你既然要Hook DBGrid,DLL自然也要做相应更改啦。<br>你用FindWindowEx找Label,不是搞笑吗?你都知道Label不是窗口组件,没有句柄啦,你找什么呀?能直接找到,还要这么麻烦干嘛?直接SendMessage发个消息不就取到Caption啦,还要这么辛苦写个DLL,写个Hook?
 
关键你的代码一点注释都没有,本来就不明白,感谢你,先揭贴,有问题还的问你
 

Similar threads

D
回复
0
查看
881
DelphiTeacher的专栏
D
D
回复
0
查看
850
DelphiTeacher的专栏
D
D
回复
0
查看
800
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部