Here's something we've been using for a while that uses the Windows API. Don't know where we pinched it from or if it's better...
FUNCTION GetSpecialFolderLocation(m.nFolderID AS Integer, m.lCreateNew AS Boolean) * Some common folder ids (refer to SHGetFolderPath in MSDN) #DEFINE CSIDL_PERSONAL 0x0005 && My Documents #DEFINE CSIDL_APPDATA 0x001a && <user name>\Application Data #DEFINE CSIDL_PROGRAM_FILES_COMMON 0x002b && C:\Program Files\Common #DEFINE CSIDL_COMMON_APPDATA 0x0023 && All Users\Application Data #DEFINE CSIDL_WINDOWS 0x0024 && GetWindowsDirectory() #DEFINE CSIDL_SYSTEM 0x0025 && GetSystemDirectory() #DEFINE CSIDL_PROGRAM_FILES 0x0026 && C:\Program Files #DEFINE CSIDL_LOCAL_APPDATA 0x001c && <user name>\Local Settings\Applicaiton Data (non roaming) #DEFINE CSIDL_FLAG_CREATE 0x8000 && create folder if not there * Misc Flags #DEFINE SHGFP_TYPE_CURRENT 0 && Return the folder's current path. #DEFINE SHGFP_TYPE_DEFAULT 1 && Return the folder's default path. LOCAL m.lcFolder,m.nRetVal IF VARTYPE(nFolderID)#"N" RETURN "" ENDIF m.lnFolder = m.nFolderID IF VARTYPE(lCreateNew)="L" AND m.lCreateNew m.lnFolder = m.lnFolder + CSIDL_FLAG_CREATE ENDIF m.lcFolder = SPACE(260) DECLARE INTEGER SHGetFolderPath IN "shfolder.dll" AS _FFC_SHGetFolderPath ; INTEGER hwndOwner, INTEGER nFolder, INTEGER hToken, INTEGER dwFlags, STRING pszPath m.nRetVal = _FFC_SHGetFolderPath(0, lnFolder, 0, SHGFP_TYPE_CURRENT, @lcFolder) CLEAR DLLS _FFC_SHGetFolderPath IF m.nRetVal <> 0 RETURN "" ENDIF RETURN ALLTRIM(CHRTRAN(m.lcFolder ,CHR(0),"")) ?GetSpecialFolderLocation(0x0005) ?GetSpecialFolderLocation(0x0023) ?GetSpecialFolderLocation(0x0024) ?GetSpecialFolderLocation(0x001c) -- rk -----Original Message----- From: profoxtech-boun...@leafe.com [mailto:profoxtech-boun...@leafe.com] On Behalf Of MB Software Solutions, LLC Sent: Tuesday, July 31, 2012 11:41 AM To: profoxt...@leafe.com Subject: Getting the My Documents folder VFP9SP2 I had this code in an older program: *** mjb 03/03/2010 - changed for Vista and beyond IF VAL(SUBSTR(OS(),9,1)) >= 6 THEN && Vista doesn't use My lcDir = lcDrive + ADDBS(GETENV("HOMEPATH")) + "Documents\MyApp2009\" ELSE && XP and below use My lcDir = lcDrive + ADDBS(GETENV("HOMEPATH")) + "My Documents\MyAppt2009\" ENDIF Is there a better way to determine the current user's My Documents folder? -- Mike Babcock, MCP _______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/DF1EEF11E586A64FB54A97F22A8BD0441DE522EF65@ACKBWDDQH1.artfact.local ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.