hay dos formas
1.- usando las variables de entorno de windows y recueprandolas con la funcion GetEnv(cNameVar)
por ejemplo:
- Code: Select all Expand view
?GetEnv("USERNAME") //regresara el nombre del usuario
ejecutando SET en la consola obtendras una series de variables que puedes recuperar.
2.- usando estas funciones.
- Code: Select all Expand view
/*-----------------------------------------------------------------------*/
#define CSIDL_PERSONAL 0x0005
/*-----------------------------------------------------------------------*/
FUNCTION GetFolderMyDocuments()
LOCAL cFolder := ""
cFolder := GetSpecialFolder( CSIDL_PERSONAL )
RETURN cFolder
/*-----------------------------------------------------------------------*/
FUNCTION GetSpecialFolder( nCSIDL )
LOCAL cFolder
cFolder := CGetSpecialFolder( nCSIDL )
RETURN cFolder
/*-----------------------------------------------------------------------*/
#pragma BEGINDUMP
#define WINVER 5
#include <shlobj.h>
#include <windows.h>
#include "hbapi.h"
HB_FUNC( CGETSPECIALFOLDER )
{
char *lpBuffer = (char*) hb_xgrab( MAX_PATH + 1 );
LPITEMIDLIST pidlBrowse;
SHGetSpecialFolderLocation( GetActiveWindow(), hb_parni(1) , &pidlBrowse);
SHGetPathFromIDList(pidlBrowse,lpBuffer);
hb_retc( lpBuffer );
hb_xfree( lpBuffer );
}
/*-----------------------------------------------------------------------*/
donde CGETSPECIALFOLDER es una funcion generica que recuperara
los nombre de los directorios que usa windows, en dependencia de la
constantes que le pasemos como parametro.
GetFolderMyDocuments es una funcion especifica, que hace uso de la
funcion anterior.
Puedes facilmente crear varias funciones que te recuperen los nombres de carpetas especificas, lo unico que necesitas son las contantes que
estan definidas en un archivo de cabezera de C, puedes buscar en el dir include de borland por esas constantes, te puede ayura intentar buscar
CSIDL_PERSONAL y encotraras las otras constantes.
salu2