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
Thanks,
Kwadwo Boahene
HTH /Michael
Longer description >>> I *NEVER* declare GLOBAL external functions; NEVER!
Instead I always declare them LOCAL PRIVATE in an NVO that wraps the external calls. One public of_xxx function may contain whole series of external calls, pre-allocate space for REF parameters, catch exceptions, map data values in enums back and forth; and so on.
No matter how complex external functionality I may need, I want the rest of my PB app to look like it is just calling any normal NVO containing any ordinary PowerScript code.