瀏覽代碼

* Started unicode changes for win32 rtl. Does not compile yet.

git-svn-id: branches/unicodertl@12124 -
yury 17 年之前
父節點
當前提交
9d48637bdd
共有 11 個文件被更改,包括 128 次插入122 次删除
  1. 21 13
      rtl/inc/file.inc
  2. 1 1
      rtl/inc/filerec.inc
  3. 10 7
      rtl/inc/system.inc
  4. 20 19
      rtl/inc/systemh.inc
  5. 20 12
      rtl/inc/text.inc
  6. 2 2
      rtl/inc/textrec.inc
  7. 18 19
      rtl/win/sysdir.inc
  8. 5 5
      rtl/win/sysfile.inc
  9. 21 38
      rtl/win/sysos.inc
  10. 0 2
      rtl/win/sysosh.inc
  11. 10 4
      rtl/win32/system.pp

+ 21 - 13
rtl/inc/file.inc

@@ -18,7 +18,7 @@
 type
   UnTypedFile=File;
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;const Name:string);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;const Name:RtlString);
 {
   Assign Name to file f so it can be used with the file routines
 }
@@ -30,21 +30,21 @@ Begin
 End;
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;p:pchar);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;p:PRtlChar);
 {
   Assign Name to file f so it can be used with the file routines
 }
 begin
-  Assign(f,StrPas(p));
+  Assign(f,p);
 end;
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;c:char);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;c:RtlChar);
 {
   Assign Name to file f so it can be used with the file routines
 }
 begin
-  Assign(f,string(c));
+  Assign(f,c);
 end;
 
 
@@ -69,7 +69,7 @@ Begin
   else
    Begin
      { Reopen with filemode 2, to be Tp compatible (PFV) }
-     Do_Open(f,PChar(@FileRec(f).Name),$1002);
+     Do_Open(f,PRtlChar(@FileRec(f).Name),$1002);
      FileRec(f).RecSize:=l;
    End;
 End;
@@ -95,7 +95,7 @@ Begin
    InOutRes:=2
   else
    Begin
-     Do_Open(f,PChar(@FileRec(f).Name),Filemode);
+     Do_Open(f,PRtlChar(@FileRec(f).Name),Filemode);
      FileRec(f).RecSize:=l;
    End;
 End;
@@ -383,25 +383,33 @@ Begin
   If InOutRes <> 0 then
    exit;
   If FileRec(f).mode=fmClosed Then
-   Do_Erase(PChar(@FileRec(f).Name));
+   Do_Erase(PRtlChar(@FileRec(f).Name));
 End;
 
 
-Procedure Rename(var f : File;p:pchar);[IOCheck];
+Procedure Rename(var f : File;p:PRtlChar);[IOCheck];
+var
+  len: longint;
 Begin
   If InOutRes <> 0 then
    exit;
   If FileRec(f).mode=fmClosed Then
    Begin
-     Do_Rename(PChar(@FileRec(f).Name),p);
+     Do_Rename(PRtlChar(@FileRec(f).Name),p);
      { check error code of do_rename }
      If InOutRes = 0 then
-        Move(p^,FileRec(f).Name,StrLen(p)+1);
+      begin
+        len:=StrLen(p)*SizeOf(RtlChar);
+        if len > SizeOf(FileRec(f).Name) - SizeOf(RtlChar) then
+          len:=SizeOf(FileRec(f).Name) - SizeOf(RtlChar);
+        Move(p^,FileRec(f).Name,len);
+        FileRec(f).Name[len]:=#0;
+      end;
    End;
 End;
 
 
-Procedure Rename(var f : File;const s : string);[IOCheck];
+Procedure Rename(var f : File;const s : RtlString);[IOCheck];
 var
   p : array[0..255] Of Char;
 Begin
@@ -413,7 +421,7 @@ Begin
 End;
 
 
-Procedure Rename(var f : File;c : char);[IOCheck];
+Procedure Rename(var f : File;c : RtlChar);[IOCheck];
 var
   p : array[0..1] Of Char;
 Begin

+ 1 - 1
rtl/inc/filerec.inc

@@ -29,6 +29,6 @@ type
     RecSize   : SizeInt;
     _private  : array[1..3 * SizeOf(SizeInt) + 5 * SizeOf (pointer)] of byte;
     UserData  : array[1..32] of byte;
-    name      : array[0..filerecnamelength] of char;
+    name      : array[0..filerecnamelength div SizeOf(RtlChar)] of RtlChar;
   End;
 

+ 10 - 7
rtl/inc/system.inc

@@ -587,7 +587,8 @@ End;
 *****************************************************************************}
 
 {$if defined(FPC_HAS_FEATURE_FILEIO) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
-Procedure getdir(drivenr:byte;Var dir:ansistring);
+(*
+Procedure getdir(drivenr:byte;Var dir:RtlString);
 { this is needed to also allow ansistrings, the shortstring version is
   OS dependent }
 var
@@ -596,6 +597,7 @@ begin
   getdir(drivenr,s);
   dir:=s;
 end;
+*)
 {$endif}
 
 {$ifopt R+}
@@ -1273,13 +1275,13 @@ end;
 *****************************************************************************}
 
 { Allow slash and backslash as separators }
-procedure DoDirSeparators(p:Pchar);
-var
-  i : longint;
+procedure DoDirSeparators(p:PRtlChar);
 begin
-  for i:=0 to strlen(p) do
-    if p[i] in AllowDirectorySeparators then
-      p[i]:=DirectorySeparator;
+  while p^ <> #0 do begin
+    if AnsiChar(p^) in AllowDirectorySeparators then
+      p^:=DirectorySeparator;
+    Inc(p);
+  end;
 end;
 
 procedure DoDirSeparators(var p:shortstring);
@@ -1337,3 +1339,4 @@ begin
   CtrlBreakHandler := Handler;
 end;
 {$ENDIF FPC_HAS_SETCTRLBREAKHANDLER}
+

+ 20 - 19
rtl/inc/systemh.inc

@@ -485,7 +485,7 @@ var
 
 {$ifndef HAS_CMDLINE}
 {Value should be changed during system initialization as appropriate.}
-var cmdline:Pchar=nil;
+var cmdline:PRtlChar=nil;
 {$endif}
 
 
@@ -728,7 +728,8 @@ Function  Sseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 ****************************************************************************}
 
 function strpas(p:pchar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
-function strlen(p:pchar):longint;external name 'FPC_PCHAR_LENGTH';
+function strlen(p:pchar):longint;external name 'FPC_PCHAR_LENGTH'; overload;
+function strlen(p:PWideChar):longint; external name 'FPC_PWIDECHAR_LENGTH'; overload;
 
 { Shortstring functions }
 Procedure Delete(var s:shortstring;index:SizeInt;count:SizeInt);
@@ -800,9 +801,9 @@ function  lowercase(const s : ansistring) : ansistring;
 ****************************************************************************}
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;const Name:string);
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;p:pchar);
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;c:char);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;const Name:RtlString);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;p:PRtlChar);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;c:RtlChar);
 Procedure Rewrite(var f:File;l:Longint);
 Procedure Rewrite(var f:File);
 Procedure Reset(var f:File;l:Longint);
@@ -825,9 +826,9 @@ Function  FileSize(var f:File):Int64;
 Procedure Seek(var f:File;Pos:Int64);
 Function  EOF(var f:File):Boolean;
 Procedure Erase(var f:File);
-Procedure Rename(var f:File;const s:string);
-Procedure Rename(var f:File;p:pchar);
-Procedure Rename(var f:File;c:char);
+Procedure Rename(var f:File;const s:RtlString);
+Procedure Rename(var f:File;p:PRtlChar);
+Procedure Rename(var f:File;c:RtlChar);
 Procedure Truncate (var F:File);
 {$endif FPC_HAS_FEATURE_FILEIO}
 
@@ -849,18 +850,18 @@ Procedure Rewrite(var f : TypedFile); [INTERNPROC: fpc_in_Rewrite_TypedFile];
 ****************************************************************************}
 
 {$ifdef FPC_HAS_FEATURE_TEXTIO}
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;const s:string);
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;p:pchar);
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;c:char);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;const s:RtlString);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;p:PRtlChar);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;c:RtlChar);
 Procedure Close(var t:Text);
 Procedure Rewrite(var t:Text);
 Procedure Reset(var t:Text);
 Procedure Append(var t:Text);
 Procedure Flush(var t:Text);
 Procedure Erase(var t:Text);
-Procedure Rename(var t:Text;const s:string);
-Procedure Rename(var t:Text;p:pchar);
-Procedure Rename(var t:Text;c:char);
+Procedure Rename(var t:Text;const s:RtlString);
+Procedure Rename(var t:Text;p:PRtlChar);
+Procedure Rename(var t:Text;c:RtlChar);
 Function  EOF(var t:Text):Boolean;
 Function  EOF:Boolean;
 Function  EOLn(var t:Text):Boolean;
@@ -880,12 +881,12 @@ Procedure SetTextLineEnding(var f:Text; Ending:string);
 
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-Procedure chdir(const s:string);
-Procedure mkdir(const s:string);
-Procedure rmdir(const s:string);
-Procedure getdir(drivenr:byte;var dir:shortstring);
+Procedure chdir(const s:RtlString);
+Procedure mkdir(const s:RtlString);
+Procedure rmdir(const s:RtlString);
+Procedure getdir(drivenr:byte;var dir:RtlString);
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
-Procedure getdir(drivenr:byte;var dir:ansistring);
+//Procedure getdir(drivenr:byte;var dir:RtlString);
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
 {$endif FPC_HAS_FEATURE_FILEIO}
 

+ 20 - 12
rtl/inc/text.inc

@@ -57,7 +57,7 @@ Begin
      exit;
    end;
   End;
-  Do_Open(t,PChar(@t.Name),Flags);
+  Do_Open(t,PRtlChar(@t.Name),Flags);
   t.CloseFunc:=@FileCloseFunc;
   t.FlushFunc:=nil;
   if t.Mode=fmInput then
@@ -75,7 +75,7 @@ Begin
 End;
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;const s:String);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;const s:RtlString);
 Begin
   FillChar(t,SizeOf(TextRec),0);
 { only set things that are not zero }
@@ -93,15 +93,15 @@ Begin
 End;
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;p:pchar);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;p:PRtlChar);
 begin
-  Assign(t,StrPas(p));
+  Assign(t,p);
 end;
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;c:char);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;c:RtlChar);
 begin
-  Assign(t,string(c));
+  Assign(t,RtlString(c));
 end;
 
 
@@ -198,25 +198,33 @@ Begin
   If InOutRes <> 0 then
    exit;
   If TextRec(t).mode=fmClosed Then
-   Do_Erase(PChar(@TextRec(t).Name));
+   Do_Erase(PRtlChar(@TextRec(t).Name));
 End;
 
 
-Procedure Rename(var t : text;p:pchar);[IOCheck];
+Procedure Rename(var t : text;p:PRtlChar);[IOCheck];
+var
+  len: longint;
 Begin
   If InOutRes <> 0 then
    exit;
   If TextRec(t).mode=fmClosed Then
    Begin
-     Do_Rename(PChar(@TextRec(t).Name),p);
+     Do_Rename(PRtlChar(@TextRec(t).Name),p);
      { check error code of do_rename }
      If InOutRes = 0 then
-         Move(p^,TextRec(t).Name,StrLen(p)+1);
+      begin
+        len:=StrLen(p)*SizeOf(RtlChar);
+        if len > SizeOf(TextRec(t).Name) - SizeOf(RtlChar) then
+          len:=SizeOf(TextRec(t).Name) - SizeOf(RtlChar);
+        Move(p^,TextRec(t).Name,len);
+        TextRec(t).Name[len]:=#0;
+      end;
    End;
 End;
 
 
-Procedure Rename(var t : Text;const s : string);[IOCheck];
+Procedure Rename(var t : Text;const s : RtlString);[IOCheck];
 var
   p : array[0..255] Of Char;
 Begin
@@ -228,7 +236,7 @@ Begin
 End;
 
 
-Procedure Rename(var t : Text;c : char);[IOCheck];
+Procedure Rename(var t : Text;c : RtlChar);[IOCheck];
 var
   p : array[0..1] Of Char;
 Begin

+ 2 - 2
rtl/inc/textrec.inc

@@ -25,7 +25,7 @@ const
   TextRecBufSize    = 256;
 type
   TLineEndStr = string [3];
-  TextBuf = array[0..TextRecBufSize-1] of char;
+  TextBuf = array[0..(TextRecBufSize div SizeOf(RtlChar))-1] of RtlChar;
   TextRec = Packed Record
     Handle    : THandle;
     Mode      : longint;
@@ -39,7 +39,7 @@ type
     flushfunc,
     closefunc : pointer;
     UserData  : array[1..32] of byte;
-    name      : array[0..textrecnamelength-1] of char;
+    name      : array[0..(TextRecNameLength div SizeOf(RtlChar))-1] of RtlChar;
     LineEnd   : TLineEndStr;
     buffer    : textbuf;
   End;

+ 18 - 19
rtl/win/sysdir.inc

@@ -19,35 +19,34 @@
 *****************************************************************************}
 
 type
- TDirFnType=function(name:pointer):longbool;stdcall;
+ TDirFnType=function(name:PRtlChar):longbool;stdcall;
 
-procedure dirfn(afunc : TDirFnType;const s:string);
+procedure dirfn(afunc : TDirFnType;const s:RtlString);
 var
-  buffer : array[0..255] of char;
+  buffer : RtlString;
 begin
-  move(s[1],buffer,length(s));
-  buffer[length(s)]:=#0;
-  DoDirSeparators(pchar(@buffer));
-  if not aFunc(@buffer) then
+  buffer:=s;
+  DoDirSeparators(PRtlChar(buffer));
+  if not aFunc(PRtlChar(buffer)) then
     begin
       errno:=GetLastError;
       Errno2InoutRes;
     end;
 end;
 
-function CreateDirectoryTrunc(name:pointer):longbool;stdcall;
+function CreateDirectoryTrunc(name:PRtlChar):longbool;stdcall;
 begin
   CreateDirectoryTrunc:=CreateDirectory(name,nil);
 end;
 
-procedure mkdir(const s:string);[IOCHECK];
+procedure mkdir(const s:RtlString);[IOCHECK];
 begin
   If (s='') or (InOutRes <> 0) then
    exit;
   dirfn(TDirFnType(@CreateDirectoryTrunc),s);
 end;
 
-procedure rmdir(const s:string);[IOCHECK];
+procedure rmdir(const s:RtlString);[IOCHECK];
 begin
   if (s ='.') then
     InOutRes := 16;
@@ -64,7 +63,7 @@ begin
 {$endif WINCE}
 end;
 
-procedure chdir(const s:string);[IOCHECK];
+procedure chdir(const s:RtlString);[IOCHECK];
 begin
 {$ifndef WINCE}
   If (s='') or (InOutRes <> 0) then
@@ -77,34 +76,34 @@ begin
 {$endif WINCE}
 end;
 
-procedure GetDir (DriveNr: byte; var Dir: ShortString);
+procedure GetDir (DriveNr: byte; var Dir: RtlString);
 {$ifndef WINCE}
 const
-  Drive:array[0..3]of char=(#0,':',#0,#0);
+  Drive:array[0..3]of RtlChar=(#0,':',#0,#0);
 var
   defaultdrive:boolean;
-  DirBuf,SaveBuf:array[0..259] of Char;
+  DirBuf,SaveBuf:array[0..259] of RtlChar;
 {$endif WINCE}
 begin
 {$ifndef WINCE}
   defaultdrive:=drivenr=0;
   if not defaultdrive then
    begin
-    byte(Drive[0]):=Drivenr+64;
-    GetCurrentDirectory(SizeOf(SaveBuf),SaveBuf);
+    Drive[0]:=RtlChar(Drivenr+64);
+    GetCurrentDirectory(High(SaveBuf)+1,SaveBuf);
     if not SetCurrentDirectory(@Drive) then
      begin
       errno := word (GetLastError);
       Errno2InoutRes;
-      Dir := char (DriveNr + 64) + ':\';
+      Dir := RtlChar (DriveNr + 64) + ':\';
       SetCurrentDirectory(@SaveBuf);
       Exit;
      end;
    end;
-  GetCurrentDirectory(SizeOf(DirBuf),DirBuf);
+  GetCurrentDirectory(High(SaveBuf)+1,DirBuf);
   if not defaultdrive then
    SetCurrentDirectory(@SaveBuf);
-  dir:=strpas(DirBuf);
+  dir:=DirBuf;
   if not FileNameCaseSensitive then
    dir:=upcase(dir);
 {$else WINCE}

+ 5 - 5
rtl/win/sysfile.inc

@@ -36,7 +36,7 @@ begin
 end;
 
 
-procedure do_erase(p : pchar);
+procedure do_erase(p : PRtlChar);
 begin
    DoDirSeparators(p);
    if DeleteFile(p)=0 then
@@ -44,7 +44,7 @@ begin
       errno:=GetLastError;
       if errno=5 then
        begin
-         if ((GetFileAttributes(p) and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY) then
+         if ((GetFileAttributes(_W(p)) and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY) then
           errno:=2;
        end;
       Errno2InoutRes;
@@ -52,7 +52,7 @@ begin
 end;
 
 
-procedure do_rename(p1,p2 : pchar);
+procedure do_rename(p1,p2 : PRtlChar);
 begin
   DoDirSeparators(p1);
   DoDirSeparators(p2);
@@ -189,7 +189,7 @@ begin
 end;
 
 
-procedure do_open(var f;p:pchar;flags:longint);
+procedure do_open(var f;p:PRtlChar;flags:longint);
 {
   filerec and textrec have both handle and mode as the first items so
   they could use the same routine for opening/creating.
@@ -276,7 +276,7 @@ begin
   security.nLength := Sizeof(TSecurityAttributes);
   security.bInheritHandle:=true;
   security.lpSecurityDescriptor:=nil;
-  filerec(f).handle:=CreateFile(p,oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0);
+  filerec(f).handle:=CreateFile(_W(p),oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0);
 
   { append mode }
   if ((flags and $100)<>0) and

+ 21 - 38
rtl/win/sysos.inc

@@ -111,15 +111,9 @@ type
    UINT  = cardinal;
    BOOL  = longbool;
 //   WCHAR = word;
-{$ifdef UNICODE}
-   LPTCH   = ^word;
-   LPTSTR  = ^word;
-   LPCTSTR = ^word;
-{$else UNICODE}
-   LPTCH   = ^char;
-   LPTSTR  = ^char;
-   LPCTSTR = ^char;
-{$endif UNICODE}
+   LPTCH   = ^wchar;
+   LPTSTR  = ^wchar;
+   LPCTSTR = ^wchar;
    LPWSTR  = ^wchar;
    PVOID   = pointer;
    LPVOID  = pointer;
@@ -187,15 +181,12 @@ threadvar
 
    { Startup }
    procedure GetStartupInfo(p : pointer);
-     stdcall;external KernelDLL name 'GetStartupInfoA';
+     stdcall;external KernelDLL name 'GetStartupInfoW';
    function GetStdHandle(nStdHandle:DWORD):THANDLE;
      stdcall;external KernelDLL name 'GetStdHandle';
 
    { command line/enviroment functions }
-   function GetCommandLine : pchar;
-     stdcall;external KernelDLL name 'GetCommandLineA';
-
-   function GetCommandLineW : pwidechar;
+   function GetCommandLine : pwidechar;
      stdcall;external KernelDLL name 'GetCommandLineW';
 
   function GetCurrentProcessId:DWORD;
@@ -206,10 +197,10 @@ threadvar
 {$endif WINCE}
 
    { module functions }
-   function GetModuleFileName(l1:longint;p:pointer;l2:longint):longint;
-     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleFileName' + ApiSuffix;
-   function GetModuleHandle(p : pointer) : PtrUInt;
-     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleHandle' + ApiSuffix;
+   function GetModuleFileName(l1:thandle;p:pwidechar;l2:dword):longint;
+     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleFileNameW';
+   function GetModuleHandle(p : pwidechar) : PtrUInt;
+     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleHandleW';
 
    { file functions }
    function WriteFile(fh:thandle;buf:pointer;len:longint;var loaded:longint;
@@ -229,30 +220,22 @@ threadvar
    function FreeLibrary(hLibModule:THandle):ByteBool; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'FreeLibrary';
 
 {$ifndef WINCE}
-   function LoadLibrary(lpLibFileName:pchar):THandle; stdcall; external KernelDLL name 'LoadLibraryA';
-   function GetFileType(Handle:thandle):DWord;
-     stdcall;external KernelDLL name 'GetFileType';
-   function GetFileAttributes(p : pchar) : dword;
-     stdcall;external KernelDLL name 'GetFileAttributesA';
-   function DeleteFile(p : pchar) : longint;
-     stdcall;external KernelDLL name 'DeleteFileA';
-   function MoveFile(old,_new : pchar) : longint;
-     stdcall;external KernelDLL name 'MoveFileA';
-   function CreateFile(lpFileName:pchar; dwDesiredAccess:DWORD; dwShareMode:DWORD;
+   function LoadLibrary(lpLibFileName:pwidechar):THandle; stdcall; external KernelDLL name 'LoadLibraryW';
+   function GetFileType(Handle:thandle):DWord; stdcall;external KernelDLL name 'GetFileType';
+   function GetFileAttributes(p : pwidechar) : dword; stdcall;external KernelDLL name 'GetFileAttributesW';
+   function DeleteFile(p : pwidechar) : longint; stdcall;external KernelDLL name 'DeleteFileW';
+   function MoveFile(old,_new : pwidechar) : longint; stdcall;external KernelDLL name 'MoveFileW';
+   function CreateFile(lpFileName:pwidechar; dwDesiredAccess:DWORD; dwShareMode:DWORD;
                        lpSecurityAttributes:PSECURITYATTRIBUTES; dwCreationDisposition:DWORD;
                        dwFlagsAndAttributes:DWORD; hTemplateFile:DWORD):THandle;
-     stdcall;external KernelDLL name 'CreateFileA';
-   function GetProcAddress(hModule:THandle; lpProcName:pchar):pointer; stdcall; external KernelDLL name 'GetProcAddress';
+     stdcall;external KernelDLL name 'CreateFileW';
+   function GetProcAddress(hModule:THandle; lpProcName:pansichar):pointer; stdcall; external KernelDLL name 'GetProcAddress';
 
    { Directory }
-   function CreateDirectory(name : pointer;sec : pointer) : longbool;
-     stdcall;external KernelDLL name 'CreateDirectoryA';
-   function RemoveDirectory(name:pointer):longbool;
-     stdcall;external KernelDLL name 'RemoveDirectoryA';
-   function SetCurrentDirectory(name : pointer) : longbool;
-     stdcall;external KernelDLL name 'SetCurrentDirectoryA';
-   function GetCurrentDirectory(bufsize : longint;name : pchar) : longbool;
-     stdcall;external KernelDLL name 'GetCurrentDirectoryA';
+   function CreateDirectory(name : pwidechar;sec : pointer) : longbool; stdcall;external KernelDLL name 'CreateDirectoryW';
+   function RemoveDirectory(name:pwidechar):longbool; stdcall;external KernelDLL name 'RemoveDirectoryW';
+   function SetCurrentDirectory(name : pwidechar) : longbool; stdcall;external KernelDLL name 'SetCurrentDirectoryW';
+   function GetCurrentDirectory(bufsize : longint;name : pwidechar) : longbool; stdcall;external KernelDLL name 'GetCurrentDirectoryW';
 
    var
      SetFilePointerEx : function(hFile : THandle;

+ 0 - 2
rtl/win/sysosh.inc

@@ -52,10 +52,8 @@ type
 const
 {$ifdef WINCE}
   KernelDLL = 'coredll';
-  ApiSuffix = 'W';
 {$else WINCE}
   KernelDLL = 'kernel32';
-  ApiSuffix = 'A';
 {$endif WINCE}
 
 function OleStrToString(source: PWideChar) : ansistring;inline;

+ 10 - 4
rtl/win32/system.pp

@@ -97,7 +97,7 @@ type
 var
 { C compatible arguments }
   argc : longint;
-  argv : ppchar;
+  argv : ^PRtlChar;
 { Win32 Info }
   startupinfo : tstartupinfo;
   hprevinst,
@@ -118,6 +118,11 @@ const
 
 implementation
 
+function _W(const s: RtlString): PWideChar; inline;
+begin
+  Result:=PWideChar(UnicodeString(s));
+end;
+
 var
   EntryInformation : TEntryInformation;
   SysInstance : Longint;public name '_FPC_SysInstance';
@@ -147,10 +152,11 @@ var
   arglen,
   count   : longint;
   argstart,
-  pc,arg  : pchar;
+  pc      : pwidechar;
+  arg     : PRtlChar;
   quote   : Boolean;
   argvlen : longint;
-  buf: array[0..259] of char;  // need MAX_PATH bytes, not 256!
+  buf: array[0..259] of WideChar;  // need MAX_PATH bytes, not 256!
 
   procedure allocarg(idx,len:longint);
     var
@@ -176,7 +182,7 @@ begin
   count:=0;
   argv:=nil;
   argvlen:=0;
-  ArgLen := GetModuleFileName(0, @buf[0], sizeof(buf));
+  ArgLen := GetModuleFileName(0, @buf[0], High(buf)-1);
   buf[ArgLen] := #0; // be safe
   allocarg(0,arglen);
   move(buf,argv[0]^,arglen+1);