(Delphi 2006) I am getting the Common documents folder in order to create another folder off it during my app startup. This has been working fine - it always returns:
C:\Documents and Settings\All Users\Documents\
but I have just received a bug report from a Spanish user that includes a startup log that shows the app was trying to create:
MyApp\
instead of:
C:\Documents and Settings\All Users\Documents\MyApp\
i.e. the common docs folder string was empty. The code to get this is:
function GetCommonDocumentsFolder : TFilename ;
begin
Result := GetSystemPath (CSIDL_COMMON_DOCUMENTS) ;
end ;
I also note in my researching of this problem that there is also a system call:
SHGetSpecialFolderPath
Which one should I be using? GetSystemPath (CSIDL_COMMON_DOCUMENTS) has worked for me (at least in English locale Windows XP).
So 2 questions really, possibly related:
(boy, this was a hard one to find tags for)
Source for the mysterious GetSystemPath:
function GetSystemPath (Folder: Integer) : TFilename ;
{ Call this function with one of the constants declared above. }
var
PIDL : PItemIDList ;
Path : LPSTR ;
AMalloc : IMalloc ;
begin
Path := StrAlloc (MAX_PATH) ;
SHGetSpecialFolderLocation (Application.Handle, Folder, PIDL) ;
if SHGetPathFromIDList (PIDL, Path) then
begin
Result := IncludeTrailingPathDelimiter (Path) ;
end
else
begin
Result := '' ;
end ; ;
SHGetMalloc(AMalloc) ;
AMalloc.Free (PIDL) ;
StrDispose (Path) ;
end;
You should call SHGetSpecialFolderPath
when you want to know the path corresponding to a CSIDL.
I don't know what GetSpecialFolderPath
is, I can't find it in my Delphi. Did you mean SHGetSpecialFolderPath
? I also can't find GetSystemPath
, but that doesn't change my answer!