Code: Select all
Procedure.s GetSysFolder(iVal.i)
;-------------------------------
#CSIDL_PROGRAM_FILES = $26 ;C:\Program Files
#CSIDL_PROGRAM_FILESX86 = $2A ;32bit C:\Program Files (x86) on 64bit
Protected iFolderID.i, iSlashTotal.i, iSlashPosn.i, sSpecialFolderLocation.s
If SHGetSpecialFolderLocation_(0, iVal, @iFolderID) = 0
sSpecialFolderLocation = Space(#MAX_PATH)
SHGetPathFromIDList_(iFolderID, @sSpecialFolderLocation)
If sSpecialFolderLocation
If Right(sSpecialFolderLocation, 1) <> "\"
sSpecialFolderLocation + "\"
EndIf
;Double backslashes:
iSlashTotal.i = CountString(sSpecialFolderLocation, "\")
iSlashPosn.i = 1
For i = 1 To iSlashTotal
iSlashPosn = FindString(sSpecialFolderLocation, "\", iSlashPosn)
sSpecialFolderLocation = InsertString(sSpecialFolderLocation, "\", iSlashPosn)
iSlashPosn = iSlashPosn + 2
Next
EndIf
CoTaskMemFree_(iFolderID)
EndIf
ProcedureReturn sSpecialFolderLocation
EndProcedure

