LogText.pas
资源名称:Wingb_Mz.rar [点击查看]
上传用户:wen198501
上传日期:2013-04-01
资源大小:335k
文件大小:1k
源码类别:
输入法编程
开发平台:
Delphi
- unit LogText;
- {$I Define.Inc}
- interface
- {$IfDef Debug}
- procedure ImeLog(x: string);
- function Int2Hex(x: Integer): string;
- {$EndIf}
- implementation
- uses Windows;
- // 调试信息记录
- procedure ImeLog(x: string);
- var
- hFile: THandle;
- xSize, wSize: DWord;
- begin
- x := x + #13#10;
- hFile := CreateFile('C:Wingb_Mz.txt', GENERIC_WRITE,
- FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
- if (hFile = INVALID_HANDLE_VALUE) then Exit;
- SetFilePointer(hFile, 0 , nil, FILE_END); // 末尾
- xSize := Length(x);
- WriteFile(hFile, x[1], xSize, wSize, nil);
- CloseHandle(hFile);
- end;
- // 数值转字符串
- function Int2Hex(x: Integer): string;
- var
- J, K: Integer;
- begin
- Result := '$00000000';
- for J := 9 downto 2 do
- begin
- K := x and $0F;
- if (K > 9) then K := K + 7;
- K := K + $30;
- Result[J] := Char(K);
- x := x shr 4;
- end;
- end;
- end.