* 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 -
This commit is contained in:
Jonas Maebe 2013-08-19 22:47:19 +00:00
parent 63e8d0c31c
commit 40ff1c77ca

View File

@ -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);