Browse Source

* updated GetWindowsSpecialDir():string so it uses the -A or -W api call
depending on whether the RTL is compiled in Unicode mode to avoid
conversions

git-svn-id: branches/cpstrrtl@25310 -

Jonas Maebe 12 years ago
parent
commit
40ff1c77ca
1 changed files with 3 additions and 4 deletions
  1. 3 4
      rtl/win/windirs.pp

+ 3 - 4
rtl/win/windirs.pp

@@ -59,8 +59,7 @@ uses
   sysutils;
 
 Type
-  PFNSHGetFolderPath = Function(Ahwnd: HWND; Csidl: Integer; Token: THandle; Flags: DWord; Path: PChar): HRESULT; stdcall;
-
+  PFNSHGetFolderPath = Function(Ahwnd: HWND; Csidl: Integer; Token: THandle; Flags: DWord; Path: {$ifdef FPC_UNICODE_RTL}PWideChar{$ELSE}PChar{$ENDIF}): HRESULT; stdcall;
 
 var
   SHGetFolderPath : PFNSHGetFolderPath = Nil;
@@ -69,7 +68,7 @@ var
 Procedure InitDLL;
 
 Var
-  pathBuf: array[0..MAX_PATH-1] of char;
+  pathBuf: array[0..MAX_PATH-1] of {$ifdef FPC_UNICODE_RTL}WideChar{$else}Ansichar{$endif};
   pathLength: Integer;
 begin
   { Load shfolder.dll using a full path, in order to prevent spoofing (Mantis #18185)
@@ -83,7 +82,7 @@ begin
 
     if (CFGDLLHandle<>0) then
     begin
-      Pointer(ShGetFolderPath):=GetProcAddress(CFGDLLHandle,'SHGetFolderPathA');
+      Pointer(ShGetFolderPath):=GetProcAddress(CFGDLLHandle,{$ifdef FPC_UNICODE_RTL}'SHGetFolderPathW'{$else}'SHGetFolderPathA'{$endif});
       If @ShGetFolderPath=nil then
       begin
         FreeLibrary(CFGDLLHandle);