Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
My doc.
Message
De
15/08/2002 09:01:02
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00689912
Message ID:
00689917
Vues:
21
This message has been marked as the solution to the initial question of the thread.
Louis,

The FoxPro Foundation Classes has a class called in _System.vcx called _CommonFolder which will help you with this. It may be VFP 7 only so the code is below.
LPARAMETERS nFolderID, lCreateNew

* 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.
#DEFINE CSIDL_FLAG_CREATE       		0x8000		  && create folder if not there


* Notes for using for Windows 2000 Logo:
*  Specific user data should be stored in a folder below CSIDL_PERSONAL
*  User application meta data (e.g., FOXUSER) should be stored in either
*  CSIDL_APPDATA or CSIDL_LOCAL_APPDATA. CSIDL_APPDATA allows you to roam on W2K.

LOCAL lcFolder,nRetVal

IF VARTYPE(nFolderID)#"N"
	RETURN ""
ENDIF

lnFolder = nFolderID
IF VARTYPE(lCreateNew)="L" AND lCreateNew
	* If the folder does not exist, then the function creates it for you,
	* fills the string buffer with the path, and returns S_OK. If you do not use the 
	* CSIDL_FLAG_CREATE flag, and the folder does not exist, then the function 
	* returns S_FALSE and nothing is placed in your string buffer.
	lnFolder = lnFolder + CSIDL_FLAG_CREATE
ENDIF

lcFolder = SPACE(260)

DECLARE INTEGER SHGetFolderPath IN "shfolder.dll" AS _FFC_SHGetFolderPath ;
    INTEGER hwndOwner, INTEGER nFolder, INTEGER hToken, INTEGER dwFlags, STRING pszPath

nRetVal = _FFC_SHGetFolderPath(0, lnFolder, 0, SHGFP_TYPE_CURRENT, @lcFolder)
CLEAR DLLS _FFC_SHGetFolderPath

IF nRetVal # 0
	RETURN ""
ENDIF

RETURN ALLTRIM(CHRTRAN(lcFolder ,CHR(0),""))
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform