Guest User

Untitled

a guest
Apr 24th, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. {
  2. Модуль "русификации" консольных приложений
  3. (c) Eugene Kasnerik, 1999
  4. e-mail: eugene1975@mail.ru
  5. (c) Nikolay Kuchma, 2010
  6. e-mail: kuchma@ksu.kz
  7. }
  8. unit RusLib;
  9.  
  10. interface
  11.  
  12. implementation
  13.  
  14. uses
  15. Windows;
  16.  
  17. type
  18. TTextRec = packed record
  19. Handle: Integer;
  20. Mode: Word;
  21. Flags: Word;
  22. BufSize: Cardinal;
  23. BufPos: Cardinal;
  24. BufEnd: Cardinal;
  25. BufPtr: PChar;
  26. OpenFunc: Pointer;
  27. InOutFunc: Pointer;
  28. FlushFunc: Pointer;
  29. CloseFunc: Pointer;
  30. UserData: array[1..32] of Byte;
  31. Name: array[0..259] of Char;
  32. Buffer: array[0..127] of Char;
  33. end;
  34.  
  35. function ConInFunc(var Text: TTextRec): Integer;
  36. const
  37. ERROR_BROKEN_PIPE = 109;
  38. begin
  39. Text.BufPos := 0;
  40. Text.BufEnd := 0;
  41. if ReadFile(Text.Handle, Text.BufPtr^, Text.BufSize, Text.BufEnd, nil)
  42. then begin
  43. if Text.BufEnd > 0 then
  44. OemToCharBuff(Text.BufPtr, Text.BufPtr, Text.BufEnd);
  45. Result := 0
  46. end
  47. else begin
  48. Result := GetLastError;
  49. if Result = ERROR_BROKEN_PIPE then
  50. Result := 0
  51. end
  52. end;
  53.  
  54. function ConOutFunc(var Text: TTextRec): Integer;
  55. var
  56. Dummy: Cardinal;
  57. begin
  58. if Text.BufPos > 0 then
  59. begin
  60. CharToOemBuff(Text.BufPtr, Text.BufPtr, Text.BufPos);
  61. if WriteFile(Text.Handle, Text.BufPtr^, Text.BufPos, Dummy, nil) then
  62. Result := 0
  63. else
  64. Result := GetLastError;
  65. Text.BufPos := 0;
  66. end
  67. else
  68. Result := 0;
  69. end;
  70.  
  71. initialization
  72. Reset(Input);
  73. TTextRec(Input).InOutFunc := @ConInFunc;
  74. TTextRec(Input).FlushFunc := @Flush;
  75. Rewrite(Output);
  76. TTextRec(Output).InOutFunc := @ConOutFunc;
  77. TTextRec(Output).FlushFunc := @ConOutFunc
  78. end.
Add Comment
Please, Sign In to add comment