I added the Windows API code below to my production PB 12.1 and Powerbuilder 2017 test applications (same exe) and this is crashing my app. The crash happens on Windows Server 2012 R2 but fine on my desktop- (Windows 7). Does anyone have an API or anything else that will work in both areas to pull the users person folder information. I using that folder to temporary write some files. PB 2017 trial had more problems because I could never debug with out randomly optimizing some pbls.
///////
API
///global external function
Function long SHGetFolderPath ( long hwndOwner, long nFolder, long hToken, long dwFlags, Ref string pszPath ) Library "shell32.dll" alias For "SHGetFolderPathW"
//// local area
Constant Long CSIDL_PERSONAL = 5 // current user My Documents
Constant Long CSIDL_APPDATA = 26 // current user Application Data
Constant Long CSIDL_LOCAL_APPDATA = 28 // local settings Application Data
Constant Long CSIDL_COMMON_DOCUMENTS = 46 // all users My Documents
Constant Long CSIDL_COMMON_APPDATA = 35 // all users Application Data
string ls_path
ulong lul_handle, lul_rc, lul_hToken
//
ls_path = Space(256)
lul_handle = Handle(This)
SetNull(lul_hToken)
lul_rc = SHGetFolderPath(lul_handle, CSIDL_PERSONAL, lul_hToken, 0, gs_personal_folder)
//
gs_personal_folder = gs_personal_folder+"\"
//
KB