sfProgramFiles or sfProgramFilesX86 returns always same

delphi package - easy access to shell apis
Post Reply
kgulol
Posts: 9
Joined: Sat Jan 07, 2012 5:42 pm

sfProgramFiles or sfProgramFilesX86 returns always same

Post by kgulol »

trying to get Program Files Directory
always returns "C:\Program Files (86)\"
but I want somethhing like that
"C:\Program Files\"
because this operating system have both directories.

so I did a small function :

function GetSpecialFolder2(AFolder: TSpecialFolder): string;
var
_ret: AnsiString;
begin
_ret := '';
madshell.GetSpecialFolder(AFolder, _ret);
Result := _ret;
end;

GetSpecialFolder2(sfProgramFilesX86)
and
GetSpecialFolder2(sfProgramFiles)
always returns
"C:\Program Files (86)\"

what causes me to not to Retrieve Correct Program Files Directory ? ("C:\Program Files\")
how can I fix this problem ?

thank you.

(Operating System is Windows Seven x64)
kgulol
Posts: 9
Joined: Sat Jan 07, 2012 5:42 pm

Re: sfProgramFiles or sfProgramFilesX86 returns always same

Post by kgulol »

'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion', ProgramFilesDir
returns correct directory for x64 programs installed
may you integrate this into madshell ?
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: sfProgramFiles or sfProgramFilesX86 returns always same

Post by madshi »

It seems there's a new API for this kind of stuff. See here:

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Supporting this would probably require me to rewrite the whole "special folder" stuff in madShell. I'd like to do that, but I don't really have the time at the moment.

FWIW, sfProgramFiles is officially supposed to return "C:\Program Files (x86)". And "sfProgramFilesX86" is officially supposed to work only for RISC systems.
Post Reply