I've just cobbled this together from bits of code here, and some stuff from MSDN.
I'm not sure if CSIDL_LOCAL_APPDATA is the one I need for Vista, but at least the above code is returning results that *seem* correct. I'll play more tomorrow.
Extern "Win32" Function SHGetSpecialFolderLocation(hwndOwner, nFolder, pIdl:Byte Ptr) Function SHGetPathFromIDList( pidList ,lpBuffer:Byte Ptr) End Extern Const CSIDL_DESKTOP = $0 Const CSIDL_INTERNET = $1 Const CSIDL_PROGRAMS = $2 Const CSIDL_CONTROLS = $3 Const CSIDL_PRINTERS = $4 Const CSIDL_PERSONAL = $5 Const CSIDL_FAVORITES = $6 Const CSIDL_STARTUP = $7 Const CSIDL_RECENT = $8 Const CSIDL_SENDTO = $9 Const CSIDL_BITBUCKET = $A Const CSIDL_STARTMENU = $B Const CSIDL_DESKTOPDIRECTORY = $10 Const CSIDL_DRIVES = $11 Const CSIDL_NETWORK = $12 Const CSIDL_NETHOOD = $13 Const CSIDL_FONTS = $14 Const CSIDL_TEMPLATES = $15 Const CSIDL_COMMON_STARTMENU = $16 Const CSIDL_COMMON_PROGRAMS = $17 Const CSIDL_COMMON_STARTUP = $18 Const CSIDL_COMMON_DESKTOPDIRECTORY = $19 Const CSIDL_APPDATA = $1A Const CSIDL_PRINTHOOD = $1B Const CSIDL_LOCAL_APPDATA = $1C Const CSIDL_ALTSTARTUP = $1D Const CSIDL_COMMON_ALTSTARTUP = $1E Const CSIDL_COMMON_FAVORITES = $1F Const CSIDL_INTERNET_CACHE = $20 Const CSIDL_COOKIES = $21 Const CSIDL_HISTORY = $22 Const CSIDL_COMMON_APPDATA = $23 Print GetSpecialFolder(CSIDL_LOCAL_APPDATA) Function GetSpecialFolder:String(folder_id) Local idl% = CreateBank (8) Local pathbank:TBank = CreateBank (260) If SHGetSpecialFolderLocation(0,folder_id,BankBuf(idl)) = 0 SHGetPathFromIDList PeekInt( idl,0), BankBuf(pathbank) Return String.FromCString(pathbank.Buf()) + "" EndIf End FunctionCredit to whoever wrote the bits I borrowed from here. I can't remember who you are, though.
I'm not sure if CSIDL_LOCAL_APPDATA is the one I need for Vista, but at least the above code is returning results that *seem* correct. I'll play more tomorrow.