Mine too. Vista Business.srod wrote:I'm probably being a little dense here!![]()
But why does Appdata.s = GetEnvironmentVariable("%appdata%") just produce an empty string on my system?
cheers

Code: Select all
dataPath.s = SpecialFolder(#CSIDL_COMMON_APPDATA) + "\" + myBusinessName.s + "\" + myAppName.s + "\"Code: Select all
Procedure.s GetKeyValue(topKey.l,sKey$,sValue$)
Protected lType.l,lpcbData.l,hKey.l,lpData$,path$
lpData$=Space(2048+1)
lpcbData=Len(lpData$)-1
If RegOpenKeyEx_(topKey,sKey$,#Null,#KEY_READ,@hKey)=#ERROR_SUCCESS
RegQueryValueEx_(hKey,sValue$,#Null,@lType,@lpData$,@lpcbData)
RegCloseKey_(hKey)
EndIf
ProcedureReturn Trim(lpData$)
EndProcedure
Procedure.s SpecialFolderLocation(csidl.l)
Protected location$,pidl.l
If SHGetSpecialFolderLocation_(#Null,csidl,@pidl)=#ERROR_SUCCESS
location$=Space(#MAX_PATH)
If SHGetPathFromIDList_(pidl,@location$)
If Right(location$,1)<>"\"
location$+"\"
EndIf
EndIf
If pidl
CoTaskMemFree_(pidl) ;Instead of messing with com imalloc free and whatnot.
EndIf
EndIf
ProcedureReturn Trim(location$)
EndProcedure
Procedure.s GetProgramFilesDir()
Protected os.l,value$,path$
os=OSVersion()
If os>#PB_OS_Windows_ME
path$=SpecialFolderLocation(#CSIDL_PROGRAM_FILES)
Else
value$=GetKeyValue(#HKEY_LOCAL_MACHINE,"Software\Microsoft\Windows\Currentversion","ProgramFilesDir")
If value$<>""
path$=value$
If Right(value$,1)<>"\"
path$+"\"
EndIf
EndIf
EndIf
If FileSize(path$)<>-2
If CreateDirectory(path$)=#False
path$=""
EndIf
EndIf
ProcedureReturn path$
EndProcedure
Procedure.s GetApplicationDataDirectory()
Protected path$
path$=SpecialFolderLocation(#CSIDL_APPDATA)
If path$="" ;Needed since Windows 95 do not support CSIDL_APPDATA "out of the box".
path$=GetProgramFilesDir()+"Application Data\"
EndIf
If FileSize(path$)<>-2
If CreateDirectory(path$)=#False
path$=""
EndIf
EndIf
ProcedureReturn path$
EndProcedure
Procedure.s GetMyDocumentsDirectory()
Protected path$
path$=SpecialFolderLocation(#CSIDL_PERSONAL) ;My Documents\ folder, use this rather than the other CSIDL
If FileSize(path$)<>-2
If CreateDirectory(path$)=#False
path$=""
EndIf
EndIf
ProcedureReturn path$
EndProcedure
Procedure.s GetTempDirectory()
Protected path$,pathlen.l,result.l
path$=Space(2048+1)
result=GetTempPath_(Len(path$)-1,@path$)
If (result=0) Or (result>Len(path$))
path$=""
Else
If Right(path$,1)<>"\"
path$+"\"
EndIf
If FileSize(path$)<>-2
If CreateDirectory(path$)=#False
path$=""
EndIf
EndIf
EndIf
ProcedureReturn path$
EndProcedure

Code: Select all
Procedure.s GetSpecialFolderPath(CSIDL.l)
Protected *itemid.ITEMIDLIST, location.s = Space(#MAX_PATH)
If SHGetSpecialFolderLocation_(0,CSIDL,@*itemid) = #NOERROR
If SHGetPathFromIDList_(*itemid,@location)
ProcedureReturn location
EndIf
EndIf
EndProcedure
Global AppdataPath$ = GetSpecialFolderPath(#CSIDL_APPDATA)
Global ProgramPath$ = GetPathPart(ProgramFilename())
If Not ProgramParameter(0) = "/portable" And FileSize("portable.txt") = -1
If Not FileSize(AppdataPath$+"\JLC's Software")=-2
CreateDirectory(AppdataPath$+"\JLC's Software")
EndIf
If Not FileSize(AppdataPath$+"\JLC's Software\Radio Player")=-2
CreateDirectory(AppdataPath$+"\JLC's Software\Radio Player")
EndIf
SetCurrentDirectory(AppdataPath$+"\JLC's Software\Radio Player")
EndIfPSDK/MSDN wrote:A pointer to an item identifier list (PIDL) specifying the folder's location relative to the root of the namespace (the desktop). The calling application is responsible for freeing this pointer