Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- Модуль "русификации" консольных приложений
- (c) Eugene Kasnerik, 1999
- e-mail: eugene1975@mail.ru
- (c) Nikolay Kuchma, 2010
- e-mail: kuchma@ksu.kz
- }
- unit RusLib;
- interface
- implementation
- uses
- Windows;
- type
- TTextRec = packed record
- Handle: Integer;
- Mode: Word;
- Flags: Word;
- BufSize: Cardinal;
- BufPos: Cardinal;
- BufEnd: Cardinal;
- BufPtr: PChar;
- OpenFunc: Pointer;
- InOutFunc: Pointer;
- FlushFunc: Pointer;
- CloseFunc: Pointer;
- UserData: array[1..32] of Byte;
- Name: array[0..259] of Char;
- Buffer: array[0..127] of Char;
- end;
- function ConInFunc(var Text: TTextRec): Integer;
- const
- ERROR_BROKEN_PIPE = 109;
- begin
- Text.BufPos := 0;
- Text.BufEnd := 0;
- if ReadFile(Text.Handle, Text.BufPtr^, Text.BufSize, Text.BufEnd, nil)
- then begin
- if Text.BufEnd > 0 then
- OemToCharBuff(Text.BufPtr, Text.BufPtr, Text.BufEnd);
- Result := 0
- end
- else begin
- Result := GetLastError;
- if Result = ERROR_BROKEN_PIPE then
- Result := 0
- end
- end;
- function ConOutFunc(var Text: TTextRec): Integer;
- var
- Dummy: Cardinal;
- begin
- if Text.BufPos > 0 then
- begin
- CharToOemBuff(Text.BufPtr, Text.BufPtr, Text.BufPos);
- if WriteFile(Text.Handle, Text.BufPtr^, Text.BufPos, Dummy, nil) then
- Result := 0
- else
- Result := GetLastError;
- Text.BufPos := 0;
- end
- else
- Result := 0;
- end;
- initialization
- Reset(Input);
- TTextRec(Input).InOutFunc := @ConInFunc;
- TTextRec(Input).FlushFunc := @Flush;
- Rewrite(Output);
- TTextRec(Output).InOutFunc := @ConOutFunc;
- TTextRec(Output).FlushFunc := @ConOutFunc
- end.
Add Comment
Please, Sign In to add comment