Hello all
I'm using the following code to get the path to the local progdata folder. On my Win7 system the result is C:\ProgramData.
#constant CSIDL_COMMON_APPDATA = 0x0023
global sLocalProgdataPath$ as string
getpath_memblock_a = 1
getpath_memblock_b = 2
getpath_dll = 1
max_path=512
if dll exist(getpath_dll)=0
load dll "shell32.dll",getpath_dll
endif
make memblock getpath_memblock_a,max_path
pszPath = get memblock ptr(getpath_memblock_a)
make memblock getpath_memblock_b,16
ppidl = get memblock ptr(getpath_memblock_b)
HRESULT = call dll(getpath_dll,"SHGetFolderLocation","",CSIDL_COMMON_APPDATA,"",0,ppidl)
if HRESULT = 0
Result = call dll(getpath_dll,"SHGetPathFromIDList", *ppidl,pszPath)
if Result = 1
for b=1 to max_path
m=memblock byte(getpath_memblock_a,b-1)
if m=0 then exit
sLocalProgdataPath$=sLocalProgdataPath$+chr$(m)
next b
endif
endif
delete memblock getpath_memblock_a
delete memblock getpath_memblock_b
My question is - is this the best way to do this? It seemed a bit unreliable on some networked WinXP systems which were members of a domain.
Thanks for any advice
James