易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

Delphi中使用DirectX截屏函数


转自:http://www.52delphi.com/List.asp?ID=597&Page=1
  核心提示:函数需要 uses Direct3D9,D3DX9; 偶然发现一个函数可以直接保存表面到文件1!所以修改了一下,函数为:...
procedure CaptureScreen(Const FileName: string);
var
BitsPerPixel: Byte;
pD3D: IDirect3D9;
pSurface: IDirect3DSurface9;
......

Delphi字符串函数大全

Delphi字符串函数大全
uses StrUtils;
【字符串函数大全】
      首部 function AnsiResemblesText(const AText, AOther: string): Boolean;
      $[StrUtils.pas
      功能 返回两个字符串是否相似
      ......

括号匹配(delphi)-转

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 注册 com 对象的方法

delphi 注册 com 对象的方法
procedure TForm1.Button3Click(Sender: TObject);
var
 Sd: TSecurityDescriptor;
 begin
   InitializeSecurityDescriptor(@Sd, SECURITY_DESCRIPTOR_REVISION);
    SetSecurityDescriptorDacl(@Sd, true, Nil, false);
    RegSe ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号