Delphi跨进程访问DBGRID
此文是根据伴水老大的实例做的小修改!
以下是个人见解,如有错误请指正:)
要想跨进程访问DBGRID,貌似只能用HOOK,写一个DLL想办法注入到目标进程。注入成功后,使DLL与目标进程在同一进程空间中(其内有一些细节问题,请参见代码),这时可以访问目标进程的VCL组件。并把VCL组件的数据通过进程通信的方式发给Sniffer进程。
如何进行注入?
可以安装一个WH_CALLWNDPROC钩子,这样当有消息在窗口函数中时,系统就会装载HOOK,即执行DLL部分。
如何发消息?
可以在DLL中设置一个自定义消息,在安装完钩子后,发送一个自定义消息至目标进程的窗口函数。
以下实例可读出另一进程的EDIT、LABEL、DBGRID等控件的值。
如何了解这个原理,跨进程读取StringGrid等控件也并非难事!
//DLL单元1
(*//
标题:窗体嗅探器
作者:王集鹄(Zswang)
博客:http://blog.csdn.net/zswang
日期:2009年3月14日
.//*)
unit Sniffer;
interface
uses Windows,DBGrids,DB;
function ExeSniffer( // 执行嗅探
AHandle: THandle; // 窗体句柄
AParam: Integer // 附加参数
): BOOL; stdcall;
implementation
// 尊重作者,转贴请注明出处 王集鹄(Zswang) 2009年3月14日
uses SysUtils, Classes, Controls, StdCtrls, Messages;
var
WM_SNIFFWINDOW: Longword;
type
TSnifferInfo = packed record
rHOOK: HHOOK;
rHandle: HWND;
rParam: Integer;
end;
PSnifferInfo = ^TSnifferInfo;
var
vMapFile: THandle;
vSnifferInfo: PSnifferInfo;
var
ControlAtom: TAtom;
ControlAtomString: string = '';
RM_GetObjectInstance: DWORD; // registered window message
function FindControl(Handle: HWnd): TWinControl;
var
OwningProcess: DWORD;
begin
Result := nil;
if (Handle <> 0) and (GetWindowThreadProcessID(Handle, OwningProcess) <> 0) and
(OwningProcess = GetCurrentProcessId) then
begin
if GlobalFindAtom(PChar(ControlAtomString)) = ControlAtom then
Result := Pointer(GetProp(Handle, MakeIntAtom(ControlAtom)))
else
Result := Pointer(SendMessage(Handle, RM_GetObjectInstance, 0, 0));
end;
end; { FindControl }
function
相关文档:
最近经常会模拟网页提交返回网页源码,然后获得网页中相应的元素,于是需要常常解析Html中相应的各种元素,网络是个好东西,搜索一番,就找到了
好几个Delphi版本的HtmlParser的类库,试着使用了几个,发现解析起来都不完整,或多或少的回出现一些问题!于是想到了如果界面上有一个浏
览器,我们可以通过WebBrowser的Docu ......
专门针对delphi的,嵌入源码的病毒
如果在 X:\Program Files\Borland\Delphi7\Lib 发现有 SysConst.bak (12KB) 和
SysConst.dcu (18KB),那么恭喜你,中招了。
http://topic.csdn.net/u/20090817/20/102ba10b-82ae-472d-a0be-6d54ce6a331b.html
http://bbs.2ccc.com/topic.asp?topicid=330829
http://bbs.2ccc.com/top ......
type
TCharStack = class(TStack)
private
function GetTop: Char;
public
function Pop: Char;
function Push(Item: Char): Char;
property Top: Char read GetTop;
end;
const
FindSet = ['(',')'];
implementation
{$R *.dfm}
{ TCharStack }
......
---
Delphi in a Unicode World Part I: What is Unicode, Why do you need
it, and How do you work with it in Delphi?
By: Nick
Hodges
原文链接:http://dn.codegear.com/article/38437
Abstract: This article discusses Unicode, how Delphi developers
can benefit from using Unicode, and ho ......
Delphi in a Unicode World Part II: New RTL Features and
Classes to Support Unicode
By: Nick
Hodges
原文链接:http://dn.codegear.com/article/38498
Abstract: This article will cover the new features of the Tiburon
Runtime Library that will help handle Unicode strings.
//
& ......