ÇóÒ»¶Îdelphi´úÂëתC#´úÂ룬¼±Ó㬿ÉÈËÃñ±ÒÖ§¸¶£¬Ð»Ð»
¼±Óá£ÁªÏµQQ£º8775262£¬Ð»Ð»¡£
ÐèÒª½øÐÐDllImportµÄµØ·½Ö±½ÓдDLLImport.·½·¨Ãû¡£
È磺DLLImport.GlobalAddAtom(¡¡);
Îļþ£ºUShare.pas
Delphi(Pascal) code:
unit UShare;
interface
uses Windows, Messages;
const
cMapFileName = 'HookSG_SharedData';
const
CM_MSGWNDCREATED = WM_USER + 1000;
CM_QUERYROW = WM_USER + 1001;
CM_QUERYCOL = WM_USER + 1002;
CM_HOOKCELL = WM_USER + 1003;
type
PShareData = ^TShareData;
TShareData = record
hkMsg: HHook;
HostPID: DWORD;
HostWnd: HWND;
DestWnd: HWND;
MsgWnd: HWND;
Text: array[0..1024] of Char;
end;
var
hMapFile: THandle;
P: PShareData;
implementation
end.
Îļþ£ºUHook.pas:
Delphi(Pascal) code:
unit UHook;
interface
uses Windows, Messages, SysUtils, Controls, Grids;
procedure InstallHook(MainWnd, DestWnd: HWND); stdcall;
procedure UninstallHook; stdcall;
function GetHookedCell: PChar; stdcall;
implementation
uses UShare;
var
ControlAtom: TAtom;
ControlAtomString: string;
RM_GetObjectInstance: DWORD; // registered window message
function FindControl(Handle: HWnd): TWinControl;
var
OwningProcess: DWORD;
begin
Ïà¹ØÎÊ´ð£º
¾ÍÊÇÒ»¸ö·þÎñ¶ËºÍÒ»¸ö¿Í»§¶Ë£¬Àï±ßÓÐһЩ¹²Óõ¥Ôª £¬ÎÒÔÚ ¹¤³ÌµÄSEARCH PATHÀïÉèÖõÄ·¾¶£¬
Àï±ßÓиö½á¹¹Ì壬ÎÒÔÚ·þÎñ¶Ë´ò¿ª£¬¼ÓÁ˳ÉÔ±£¬µ«ÊÇÎÒÔÚ¿Í»§¶ËÆäËûµ¥Ôª·ÃÎʲ»µ½ÎÒмӵģ¬ÎÒÔÚ¿Í»§¶Ë´ò¿ªÄǸöµ¥Ôª£¬È·Êµ¼ÓÁ ......
procedure RunFunction;
type
TFunc = function(A: Integer): Integer;stdcall;¡¡//ÕâÀï¸ù¾ÝDLLÀïÃ溯ÊýµÄÉùÃ÷ÐÞ¸Ä
var
......
¸÷λ¸ßÊָϿì°ï°ïæ¡£
ÏÖÔÚÓÐÒ»¸ödelphiдµÄdll£¬º¯ÊýÖÐÓÐPIntegerµÄ·µ»Ø²ÎÊý£¬ÔÚdelphiÖпÉÒÔÕý³£µ÷Ó㬵«ÊÇÎÒÔÚvbÀïдµÄʱºò¾Í²»ÖªµÀ¸ÃÔõôÀ´µ÷ÓÃÁË¡£
Çë¿´´úÂë
ÒÔÏÂÊÇdelphiÖеĺ¯Êý¶¨ÒåºÍµ÷ÓôúÂ룬ÄÜÕý³£ÔËÐ ......
¿ÉÄÜÒòΪ¹¤×÷µÄÔÒò ½Ó´¥Êý¾Ý¿âÕâ¿é±È½ÏÉÙ£¬Ö®Ç°¶¼ÊÇ×ö³ÌÐòÕâ¿é£¬Êý¾Ý¿âÕâ¿é¶¼ÓÐרÃŵÄÈËÀ´×ö ·Ö¹¤¶¼ºÜÃ÷ϸ ËùÒÔ¶ÔÊý¾Ý¿âÕâÒ»¿éÍêÈ«²»Á˽⡣ǰ¶Îʱ¼ä È¥ÃæÊÔÁ˼¸¼Ò¹«Ë¾ ¼¸ºõ¶¼ÊÇÔÚÊý¾Ý¿âÕâ¿é¹ÒµôµÄ Á¬¸ö¼òµ¥µÄSQ ......