'=========================================================================== ' Subject: GET APPLICATION DATA FOLDER Date: 10-14-99 (14:40) ' Author: Dave Navarro, Jr. Code: PBCC, PBDLL ' Origin: dave@powerbasic.com Packet: PBCC.ABC '=========================================================================== ' ' Return the user's defined Application Data folder ' Works in PB/DLL and PB/CC ' Ported from VB code by Dave Navarro, Jr. (dave@powerbasic.com) ' %NOERROR = 0 %MAX_LENGTH = 260 %CSIDL_APPDATA = &H1A ' Declare Public variables. TYPE ShortItemId cb AS LONG abID AS BYTE END TYPE TYPE ITEMIDLIST mkid AS ShortItemId END TYPE ' Declare API functions. DECLARE FUNCTION SHGetPathFromIDList LIB "shell32.dll" ALIAS "SHGetPathFromIDList" (BYVAL pidl AS LONG, pszPath AS ASCIIZ) AS LONG DECLARE FUNCTION SHGetSpecialFolderLocation LIB "shell32.dll" ALIAS "SHGetSpecialFolderLocation" (BYVAL hwndOwner AS LONG, BYVAL nFolder AS LONG, pidl AS ITEMIDLIST) AS LONG FUNCTION GetApplicationDataFolder( strFolder AS STRING ) AS LONG ' Returns Zero if Successful, 1 otherwise. ' This function returns the StartUp Folder Path found ' in the Current Users Profile. LOCAL idlstr AS LONG LOCAL sPath AS ASCIIZ * %MAX_LENGTH LOCAL IDL AS ITEMIDLIST LOCAL GetSpecialFolder AS STRING ' Fill the idl structure with the specified folder item. idlstr = SHGetSpecialFolderLocation( 0, %CSIDL_APPDATA, IDL ) IF idlstr = %NOERROR THEN ' Get the path from the idl list, and return ' the folder with a slash at the end. idlstr = SHGetPathFromIDList(IDL.mkid.cb, sPath) IF idlstr THEN strFolder = RTRIM$(sPath, "\") & "\" FUNCTION = 0 END IF ELSE FUNCTION = 1 END IF END FUNCTION