syswin.inc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2008 by Florian Klaempfl and Pavel Ozerski
  4. member of the Free Pascal development team.
  5. FPC Pascal system unit part shared by win32/win64.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. Error code definitions for the Win32 API functions
  14. Values are 32 bit values layed out as follows:
  15. 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  16. 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  17. +---+-+-+-----------------------+-------------------------------+
  18. |Sev|C|R| Facility | Code |
  19. +---+-+-+-----------------------+-------------------------------+
  20. where
  21. Sev - is the severity code
  22. 00 - Success
  23. 01 - Informational
  24. 10 - Warning
  25. 11 - Error
  26. C - is the Customer code flag
  27. R - is a reserved bit
  28. Facility - is the facility code
  29. Code - is the facility's status code
  30. }
  31. const
  32. SEVERITY_SUCCESS = $00000000;
  33. SEVERITY_INFORMATIONAL = $40000000;
  34. SEVERITY_WARNING = $80000000;
  35. SEVERITY_ERROR = $C0000000;
  36. const
  37. STATUS_SEGMENT_NOTIFICATION = $40000005;
  38. DBG_TERMINATE_THREAD = $40010003;
  39. DBG_TERMINATE_PROCESS = $40010004;
  40. DBG_CONTROL_C = $40010005;
  41. DBG_CONTROL_BREAK = $40010008;
  42. STATUS_GUARD_PAGE_VIOLATION = $80000001;
  43. STATUS_DATATYPE_MISALIGNMENT = $80000002;
  44. STATUS_BREAKPOINT = $80000003;
  45. STATUS_SINGLE_STEP = $80000004;
  46. DBG_EXCEPTION_NOT_HANDLED = $80010001;
  47. STATUS_ACCESS_VIOLATION = $C0000005;
  48. STATUS_IN_PAGE_ERROR = $C0000006;
  49. STATUS_INVALID_HANDLE = $C0000008;
  50. STATUS_NO_MEMORY = $C0000017;
  51. STATUS_ILLEGAL_INSTRUCTION = $C000001D;
  52. STATUS_NONCONTINUABLE_EXCEPTION = $C0000025;
  53. STATUS_INVALID_DISPOSITION = $C0000026;
  54. STATUS_ARRAY_BOUNDS_EXCEEDED = $C000008C;
  55. STATUS_FLOAT_DENORMAL_OPERAND = $C000008D;
  56. STATUS_FLOAT_DIVIDE_BY_ZERO = $C000008E;
  57. STATUS_FLOAT_INEXACT_RESULT = $C000008F;
  58. STATUS_FLOAT_INVALID_OPERATION = $C0000090;
  59. STATUS_FLOAT_OVERFLOW = $C0000091;
  60. STATUS_FLOAT_STACK_CHECK = $C0000092;
  61. STATUS_FLOAT_UNDERFLOW = $C0000093;
  62. STATUS_INTEGER_DIVIDE_BY_ZERO = $C0000094;
  63. STATUS_INTEGER_OVERFLOW = $C0000095;
  64. STATUS_PRIVILEGED_INSTRUCTION = $C0000096;
  65. STATUS_STACK_OVERFLOW = $C00000FD;
  66. STATUS_CONTROL_C_EXIT = $C000013A;
  67. STATUS_FLOAT_MULTIPLE_FAULTS = $C00002B4;
  68. STATUS_FLOAT_MULTIPLE_TRAPS = $C00002B5;
  69. STATUS_REG_NAT_CONSUMPTION = $C00002C9;
  70. EXCEPTION_EXECUTE_HANDLER = 1;
  71. EXCEPTION_CONTINUE_EXECUTION = -1;
  72. EXCEPTION_CONTINUE_SEARCH = 0;
  73. CONTEXT_X86 = $00010000;
  74. CONTEXT_CONTROL = CONTEXT_X86 or $00000001;
  75. CONTEXT_INTEGER = CONTEXT_X86 or $00000002;
  76. CONTEXT_SEGMENTS = CONTEXT_X86 or $00000004;
  77. CONTEXT_FLOATING_POINT = CONTEXT_X86 or $00000008;
  78. CONTEXT_DEBUG_REGISTERS = CONTEXT_X86 or $00000010;
  79. CONTEXT_EXTENDED_REGISTERS = CONTEXT_X86 or $00000020;
  80. CONTEXT_FULL = CONTEXT_CONTROL or CONTEXT_INTEGER or CONTEXT_SEGMENTS;
  81. MAXIMUM_SUPPORTED_EXTENSION = 512;
  82. {*****************************************************************************
  83. Parameter Handling
  84. *****************************************************************************}
  85. procedure setup_arguments;
  86. var
  87. arglen,
  88. count : longint;
  89. argstart,
  90. pc,arg : pchar;
  91. quote : Boolean;
  92. argvlen : longint;
  93. buf: array[0..259] of char; // need MAX_PATH bytes, not 256!
  94. procedure allocarg(idx,len:longint);
  95. var
  96. oldargvlen : longint;
  97. begin
  98. if idx>=argvlen then
  99. begin
  100. oldargvlen:=argvlen;
  101. argvlen:=(idx+8) and (not 7);
  102. sysreallocmem(argv,argvlen*sizeof(pointer));
  103. fillchar(argv[oldargvlen],(argvlen-oldargvlen)*sizeof(pointer),0);
  104. end;
  105. { use realloc to reuse already existing memory }
  106. { always allocate, even if length is zero, since }
  107. { the arg. is still present! }
  108. sysreallocmem(argv[idx],len+1);
  109. end;
  110. begin
  111. { create commandline, it starts with the executed filename which is argv[0] }
  112. { Win32 passes the command NOT via the args, but via getmodulefilename}
  113. count:=0;
  114. argv:=nil;
  115. argvlen:=0;
  116. ArgLen := GetModuleFileName(0, @buf[0], sizeof(buf));
  117. buf[ArgLen] := #0; // be safe
  118. allocarg(0,arglen);
  119. move(buf,argv[0]^,arglen+1);
  120. { Setup cmdline variable }
  121. cmdline:=GetCommandLine;
  122. { process arguments }
  123. pc:=cmdline;
  124. {$IfDef SYSTEM_DEBUG_STARTUP}
  125. Writeln(stderr,'Win32 GetCommandLine is #',pc,'#');
  126. {$EndIf }
  127. while pc^<>#0 do
  128. begin
  129. { skip leading spaces }
  130. while pc^ in [#1..#32] do
  131. inc(pc);
  132. if pc^=#0 then
  133. break;
  134. { calc argument length }
  135. quote:=False;
  136. argstart:=pc;
  137. arglen:=0;
  138. while (pc^<>#0) do
  139. begin
  140. case pc^ of
  141. #1..#32 :
  142. begin
  143. if quote then
  144. inc(arglen)
  145. else
  146. break;
  147. end;
  148. '"' :
  149. if pc[1]<>'"' then
  150. quote := not quote
  151. else
  152. inc(pc);
  153. else
  154. inc(arglen);
  155. end;
  156. inc(pc);
  157. end;
  158. { copy argument }
  159. { Don't copy the first one, it is already there.}
  160. If Count<>0 then
  161. begin
  162. allocarg(count,arglen);
  163. quote:=False;
  164. pc:=argstart;
  165. arg:=argv[count];
  166. while (pc^<>#0) do
  167. begin
  168. case pc^ of
  169. #1..#32 :
  170. begin
  171. if quote then
  172. begin
  173. arg^:=pc^;
  174. inc(arg);
  175. end
  176. else
  177. break;
  178. end;
  179. '"' :
  180. if pc[1]<>'"' then
  181. quote := not quote
  182. else
  183. inc(pc);
  184. else
  185. begin
  186. arg^:=pc^;
  187. inc(arg);
  188. end;
  189. end;
  190. inc(pc);
  191. end;
  192. arg^:=#0;
  193. end;
  194. {$IfDef SYSTEM_DEBUG_STARTUP}
  195. Writeln(stderr,'dos arg ',count,' #',arglen,'#',argv[count],'#');
  196. {$EndIf SYSTEM_DEBUG_STARTUP}
  197. inc(count);
  198. end;
  199. { get argc }
  200. argc:=count;
  201. { free unused memory, leaving a nil entry at the end }
  202. sysreallocmem(argv,(count+1)*sizeof(pointer));
  203. argv[count] := nil;
  204. end;
  205. function paramcount : longint;
  206. begin
  207. paramcount := argc - 1;
  208. end;
  209. function paramstr(l : longint) : string;
  210. begin
  211. if (l>=0) and (l<argc) then
  212. paramstr:=strpas(argv[l])
  213. else
  214. paramstr:='';
  215. end;
  216. procedure randomize;
  217. begin
  218. randseed:=GetTickCount;
  219. end;
  220. Var
  221. DLLInitState : Longint = -1;
  222. DLLBuf : Jmp_buf;
  223. function Dll_entry{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}(const info : TEntryInformation){$endif FPC_HAS_INDIRECT_MAIN_INFORMATION} : longbool; [public,alias:'_FPC_DLL_Entry'];
  224. begin
  225. {$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
  226. EntryInformation:=info;
  227. {$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
  228. IsLibrary:=true;
  229. DllInitState:=DLLreason;
  230. Dll_entry:=false; { return value is ignored, except when DLLreason=DLL_PROCESS_ATTACH }
  231. case DLLreason of
  232. DLL_PROCESS_ATTACH :
  233. begin
  234. MainThreadIdWin32 := Win32GetCurrentThreadId;
  235. If SetJmp(DLLBuf) = 0 then
  236. begin
  237. {$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
  238. EntryInformation.PascalMain();
  239. {$else FPC_HAS_INDIRECT_MAIN_INFORMATION}
  240. PascalMain;
  241. {$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
  242. Dll_entry:=true;
  243. end
  244. else
  245. Dll_entry:=(ExitCode=0);
  246. end;
  247. DLL_THREAD_ATTACH :
  248. begin
  249. { SysInitMultithreading must not be called here,
  250. see comments in exec_tls_callback below }
  251. { Allocate Threadvars }
  252. SysAllocateThreadVars;
  253. { NS : no idea what is correct to pass here - pass dummy value for now }
  254. { passing a dummy is ok, the correct value is read from the coff header of SysInstance (FK) }
  255. InitThread($1000000); { Assume everything is idempotent there, as the thread could have been created with BeginThread... }
  256. if assigned(Dll_Thread_Attach_Hook) then
  257. Dll_Thread_Attach_Hook(DllParam);
  258. end;
  259. DLL_THREAD_DETACH :
  260. begin
  261. if assigned(Dll_Thread_Detach_Hook) then
  262. Dll_Thread_Detach_Hook(DllParam);
  263. { Release Threadvars }
  264. if TlsGetValue(TLSKey)<>nil then
  265. DoneThread; { Assume everything is idempotent there }
  266. end;
  267. DLL_PROCESS_DETACH :
  268. begin
  269. if MainThreadIDWin32=0 then // already been here.
  270. exit;
  271. If SetJmp(DLLBuf) = 0 then
  272. begin
  273. if assigned(Dll_Process_Detach_Hook) then
  274. Dll_Process_Detach_Hook(DllParam);
  275. InternalExit;
  276. end;
  277. SysReleaseThreadVars;
  278. { Free TLS resources used by ThreadVars }
  279. SysFiniMultiThreading;
  280. MainThreadIDWin32:=0;
  281. end;
  282. end;
  283. DllInitState:=-1;
  284. end;
  285. {****************************************************************************
  286. Error Message writing using messageboxes
  287. ****************************************************************************}
  288. function MessageBox(w1:longint;l1,l2:pointer;w2:longint):longint;
  289. stdcall;external 'user32' name 'MessageBoxA';
  290. const
  291. ErrorBufferLength = 1024;
  292. var
  293. ErrorBuf : array[0..ErrorBufferLength] of char;
  294. ErrorLen : SizeInt;
  295. Function ErrorWrite(Var F: TextRec): Integer;
  296. {
  297. An error message should always end with #13#10#13#10
  298. }
  299. var
  300. i : SizeInt;
  301. Begin
  302. while F.BufPos>0 do
  303. begin
  304. begin
  305. if F.BufPos+ErrorLen>ErrorBufferLength then
  306. i:=ErrorBufferLength-ErrorLen
  307. else
  308. i:=F.BufPos;
  309. Move(F.BufPtr^,ErrorBuf[ErrorLen],i);
  310. inc(ErrorLen,i);
  311. ErrorBuf[ErrorLen]:=#0;
  312. end;
  313. if ErrorLen=ErrorBufferLength then
  314. begin
  315. MessageBox(0,@ErrorBuf,pchar('Error'),0);
  316. ErrorLen:=0;
  317. end;
  318. Dec(F.BufPos,i);
  319. end;
  320. ErrorWrite:=0;
  321. End;
  322. Function ErrorClose(Var F: TextRec): Integer;
  323. begin
  324. if ErrorLen>0 then
  325. begin
  326. MessageBox(0,@ErrorBuf,pchar('Error'),0);
  327. ErrorLen:=0;
  328. end;
  329. ErrorLen:=0;
  330. ErrorClose:=0;
  331. end;
  332. Function ErrorOpen(Var F: TextRec): Integer;
  333. Begin
  334. TextRec(F).InOutFunc:=@ErrorWrite;
  335. TextRec(F).FlushFunc:=@ErrorWrite;
  336. TextRec(F).CloseFunc:=@ErrorClose;
  337. ErrorLen:=0;
  338. ErrorOpen:=0;
  339. End;
  340. procedure AssignError(Var T: Text);
  341. begin
  342. Assign(T,'');
  343. TextRec(T).OpenFunc:=@ErrorOpen;
  344. Rewrite(T);
  345. end;
  346. procedure SysInitStdIO;
  347. begin
  348. { Setup stdin, stdout and stderr, for GUI apps redirect stderr,stdout to be
  349. displayed in a messagebox }
  350. StdInputHandle:=longint(GetStdHandle(cardinal(STD_INPUT_HANDLE)));
  351. StdOutputHandle:=longint(GetStdHandle(cardinal(STD_OUTPUT_HANDLE)));
  352. StdErrorHandle:=longint(GetStdHandle(cardinal(STD_ERROR_HANDLE)));
  353. if not IsConsole then
  354. begin
  355. AssignError(stderr);
  356. AssignError(StdOut);
  357. Assign(Output,'');
  358. Assign(Input,'');
  359. Assign(ErrOutput,'');
  360. end
  361. else
  362. begin
  363. OpenStdIO(Input,fmInput,StdInputHandle);
  364. OpenStdIO(Output,fmOutput,StdOutputHandle);
  365. OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
  366. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  367. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  368. end;
  369. end;
  370. { ProcessID cached to avoid repeated calls to GetCurrentProcess. }
  371. var
  372. ProcessID: SizeUInt;
  373. function GetProcessID: SizeUInt;
  374. begin
  375. GetProcessID := ProcessID;
  376. end;
  377. {******************************************************************************
  378. Unicode
  379. ******************************************************************************}
  380. const
  381. { MultiByteToWideChar }
  382. MB_PRECOMPOSED = 1;
  383. WC_NO_BEST_FIT_CHARS = $400;
  384. function MultiByteToWideChar(CodePage:UINT; dwFlags:DWORD; lpMultiByteStr:PChar; cchMultiByte:longint; lpWideCharStr:PWideChar;cchWideChar:longint):longint;
  385. stdcall; external 'kernel32' name 'MultiByteToWideChar';
  386. function WideCharToMultiByte(CodePage:UINT; dwFlags:DWORD; lpWideCharStr:PWideChar; cchWideChar:longint; lpMultiByteStr:PChar;cchMultiByte:longint; lpDefaultChar:PChar; lpUsedDefaultChar:pointer):longint;
  387. stdcall; external 'kernel32' name 'WideCharToMultiByte';
  388. function CharUpperBuff(lpsz:LPWSTR; cchLength:DWORD):DWORD;
  389. stdcall; external 'user32' name 'CharUpperBuffW';
  390. function CharLowerBuff(lpsz:LPWSTR; cchLength:DWORD):DWORD;
  391. stdcall; external 'user32' name 'CharLowerBuffW';
  392. procedure Win32Unicode2AnsiMove(source:punicodechar;var dest:RawByteString;cp : TSystemCodePage;len:SizeInt);
  393. var
  394. destlen: SizeInt;
  395. begin
  396. // retrieve length including trailing #0
  397. // not anymore, because this must also be usable for single characters
  398. destlen:=WideCharToMultiByte(cp, 0, source, len, nil, 0, nil, nil);
  399. // this will null-terminate
  400. setlength(dest, destlen);
  401. if destlen>0 then
  402. begin
  403. WideCharToMultiByte(cp, 0, source, len, @dest[1], destlen, nil, nil);
  404. PAnsiRec(pointer(dest)-AnsiFirstOff)^.CodePage:=cp;
  405. end;
  406. end;
  407. procedure Win32Ansi2UnicodeMove(source:pchar;cp : TSystemCodePage;var dest:UnicodeString;len:SizeInt);
  408. var
  409. destlen: SizeInt;
  410. dwflags: DWORD;
  411. begin
  412. // retrieve length including trailing #0
  413. // not anymore, because this must also be usable for single characters
  414. if cp=CP_UTF8 then
  415. dwFlags:=0
  416. else
  417. dwFlags:=MB_PRECOMPOSED;
  418. destlen:=MultiByteToWideChar(cp, dwFlags, source, len, nil, 0);
  419. // this will null-terminate
  420. setlength(dest, destlen);
  421. if destlen>0 then
  422. begin
  423. MultiByteToWideChar(cp, dwFlags, source, len, @dest[1], destlen);
  424. PUnicodeRec(pointer(dest)-UnicodeFirstOff)^.CodePage:=CP_UTF16;
  425. end;
  426. end;
  427. function Win32UnicodeUpper(const s : UnicodeString) : UnicodeString;
  428. begin
  429. result:=s;
  430. UniqueString(result);
  431. if length(result)>0 then
  432. CharUpperBuff(LPWSTR(result),length(result));
  433. end;
  434. function Win32UnicodeLower(const s : UnicodeString) : UnicodeString;
  435. begin
  436. result:=s;
  437. UniqueString(result);
  438. if length(result)>0 then
  439. CharLowerBuff(LPWSTR(result),length(result));
  440. end;
  441. {******************************************************************************
  442. Widestring
  443. ******************************************************************************}
  444. procedure Win32Ansi2WideMove(source:pchar;cp : TSystemCodePage;var dest:widestring;len:SizeInt);
  445. var
  446. destlen: SizeInt;
  447. dwFlags: DWORD;
  448. begin
  449. // retrieve length including trailing #0
  450. // not anymore, because this must also be usable for single characters
  451. if cp=CP_UTF8 then
  452. dwFlags:=0
  453. else
  454. dwFlags:=MB_PRECOMPOSED;
  455. destlen:=MultiByteToWideChar(cp, dwFlags, source, len, nil, 0);
  456. // this will null-terminate
  457. setlength(dest, destlen);
  458. if destlen>0 then
  459. MultiByteToWideChar(cp, dwFlags, source, len, @dest[1], destlen);
  460. end;
  461. function Win32WideUpper(const s : WideString) : WideString;
  462. begin
  463. result:=s;
  464. if length(result)>0 then
  465. CharUpperBuff(LPWSTR(result),length(result));
  466. end;
  467. function Win32WideLower(const s : WideString) : WideString;
  468. begin
  469. result:=s;
  470. if length(result)>0 then
  471. CharLowerBuff(LPWSTR(result),length(result));
  472. end;
  473. type
  474. PWStrInitEntry = ^TWStrInitEntry;
  475. TWStrInitEntry = record
  476. addr: PPointer;
  477. data: Pointer;
  478. end;
  479. PWStrInitTablesTable = ^TWStrInitTablesTable;
  480. TWStrInitTablesTable = packed record
  481. count : longint;
  482. tables : packed array [1..32767] of PWStrInitEntry;
  483. end;
  484. {$if not(defined(VER2_2) or defined(VER2_4))}
  485. var
  486. WStrInitTablesTable: TWStrInitTablesTable; external name 'FPC_WIDEINITTABLES';
  487. {$endif}
  488. function GetACP:UINT; stdcall; external 'kernel32' name 'GetACP';
  489. function GetConsoleCP:UINT; stdcall; external 'kernel32' name 'GetConsoleCP';
  490. function Win32GetStandardCodePage(const stdcp: TStandardCodePageEnum): TSystemCodePage;
  491. begin
  492. case stdcp of
  493. scpAnsi,
  494. scpFileSystemSingleByte: Result := GetACP;
  495. scpConsoleInput: Result := GetConsoleCP;
  496. scpConsoleOutput: Result := GetConsoleOutputCP;
  497. end;
  498. end;
  499. { there is a similiar procedure in sysutils which inits the fields which
  500. are only relevant for the sysutils units }
  501. procedure InitWin32Widestrings;
  502. var
  503. i: longint;
  504. ptable: PWStrInitEntry;
  505. begin
  506. {$if not(defined(VER2_2) or defined(VER2_4))}
  507. { assign initial values to global Widestring typed consts }
  508. for i:=1 to WStrInitTablesTable.count do
  509. begin
  510. ptable:=WStrInitTablesTable.tables[i];
  511. while Assigned(ptable^.addr) do
  512. begin
  513. fpc_widestr_assign(ptable^.addr^, ptable^.data);
  514. Inc(ptable);
  515. end;
  516. end;
  517. {$endif}
  518. { Note: since WideChar=UnicodeChar and PWideChar=PUnicodeChar,
  519. Wide2AnsiMoveProc is identical to Unicode2AnsiStrMoveProc. }
  520. { Widestring }
  521. widestringmanager.Wide2AnsiMoveProc:=@Win32Unicode2AnsiMove;
  522. widestringmanager.Ansi2WideMoveProc:=@Win32Ansi2WideMove;
  523. widestringmanager.UpperWideStringProc:=@Win32WideUpper;
  524. widestringmanager.LowerWideStringProc:=@Win32WideLower;
  525. { Unicode }
  526. widestringmanager.Unicode2AnsiMoveProc:=@Win32Unicode2AnsiMove;
  527. widestringmanager.Ansi2UnicodeMoveProc:=@Win32Ansi2UnicodeMove;
  528. widestringmanager.UpperUnicodeStringProc:=@Win32UnicodeUpper;
  529. widestringmanager.LowerUnicodeStringProc:=@Win32UnicodeLower;
  530. { Codepage }
  531. widestringmanager.GetStandardCodePageProc:=@Win32GetStandardCodePage;
  532. DefaultSystemCodePage:=GetACP;
  533. DefaultUnicodeCodePage:=CP_UTF16;
  534. DefaultFileSystemCodePage:=DefaultSystemCodePage;
  535. DefaultRTLFileSystemCodePage:=DefaultFileSystemCodePage;
  536. end;