una pequeña duda

una pequeña duda

Postby QAZWSX2K » Thu Nov 27, 2008 2:46 pm

saludos a todos, asi como existe getwindir() y getsysdir() para obtener la ruta del windows y la ruta de la carpeta system, ¿existe alguna para obtener la ruta de "Mis Documentos"?

gracias de antemano
Software especializado para oficinas contables con grandes volumenes de Informacion
Impresion de todos los formularios del Seniat, Dian

alex_patino74@hotmail.com
whatsapp 57+3214777217
User avatar
QAZWSX2K
 
Posts: 363
Joined: Tue Oct 25, 2005 7:06 pm
Location: Bogota - Caracas

Postby JOSEMAR » Thu Nov 27, 2008 6:23 pm

EN LA LINEA DE COMANDO DEL MSDOS DA SET Y TE DARA UNA LISTADE VARIABLES Y UTILIZANDIO Getenv("computername") EN TU PROGRAMA POR EJEM. SE PUEDEN HACER ALGUNAS COSAS EN FIN A LOMEJOR SE TE OCURRA ALGO.
SALUDOS, JOSE MARQUEZ
JUAN DIAZ COVARRUBIAS,VERACRUZ ,MEXICO
JOSEMAR
 
Posts: 73
Joined: Thu Dec 06, 2007 4:51 pm
Location: J.D.COVARRUBIAS,VER.,MEXICO

Postby carlos vargas » Thu Nov 27, 2008 7:04 pm

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
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1688
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Postby QAZWSX2K » Thu Nov 27, 2008 7:26 pm

GRACIAS A AMBOS, PROBARE A VER QUE TAL
Software especializado para oficinas contables con grandes volumenes de Informacion
Impresion de todos los formularios del Seniat, Dian

alex_patino74@hotmail.com
whatsapp 57+3214777217
User avatar
QAZWSX2K
 
Posts: 363
Joined: Tue Oct 25, 2005 7:06 pm
Location: Bogota - Caracas

Re: una pequeña duda

Postby Sistem » Sun Feb 23, 2014 5:32 pm

amigos

hay comando a la carpeta program files?

gracias
FWH2008 | xHarbour | BCC74 | SQLRDD
User avatar
Sistem
 
Posts: 226
Joined: Sun May 13, 2012 7:52 am

Re: una pequeña duda

Postby cnavarro » Sun Feb 23, 2014 6:21 pm

Aplicando la funcion anterior:

#define CSIDL_DESKTOP 0x0000 // <desktop>
#define CSIDL_INTERNET 0x0001 // Internet Explorer (icon on desktop)
#define CSIDL_PROGRAMS 0x0002 // Start Menu\Programs
#define CSIDL_CONTROLS 0x0003 // My Computer\Control Panel
#define CSIDL_PRINTERS 0x0004 // My Computer\Printers
#define CSIDL_PERSONAL 0x0005 // My Documents
#define CSIDL_FAVORITES 0x0006 // <user name>\Favorites
#define CSIDL_STARTUP 0x0007 // Start Menu\Programs\Startup
#define CSIDL_RECENT 0x0008 // <user name>\Recent
#define CSIDL_SENDTO 0x0009 // <user name>\SendTo
#define CSIDL_BITBUCKET 0x000a // <desktop>\Recycle Bin
#define CSIDL_STARTMENU 0x000b // <user name>\Start Menu
#define CSIDL_MYDOCUMENTS 0x000c // logical "My Documents" desktop icon
#define CSIDL_MYMUSIC 0x000d // "My Music" folder
#define CSIDL_MYVIDEO 0x000e // "My Videos" folder
#define CSIDL_DESKTOPDIRECTORY 0x0010 // <user name>\Desktop
#define CSIDL_DRIVES 0x0011 // My Computer
#define CSIDL_NETWORK 0x0012 // Network Neighborhood (My Network Places)
#define CSIDL_NETHOOD 0x0013 // <user name>\nethood
#define CSIDL_FONTS 0x0014 // windows\fonts
#define CSIDL_TEMPLATES 0x0015
#define CSIDL_COMMON_STARTMENU 0x0016 // All Users\Start Menu
#define CSIDL_COMMON_PROGRAMS 0X0017 // All Users\Start Menu\Programs
#define CSIDL_COMMON_STARTUP 0x0018 // All Users\Startup
#define CSIDL_COMMON_DESKTOPDIRECTORY 0x0019 // All Users\Desktop
#define CSIDL_APPDATA 0x001a // <user name>\Application Data
#define CSIDL_PRINTHOOD 0x001b // <user name>\PrintHood

#ifndef CSIDL_LOCAL_APPDATA
#define CSIDL_LOCAL_APPDATA 0x001c // <user name>\Local Settings\Applicaiton Data (non roaming)
#endif // CSIDL_LOCAL_APPDATA

#define CSIDL_ALTSTARTUP 0x001d // non localized startup
#define CSIDL_COMMON_ALTSTARTUP 0x001e // non localized common startup
#define CSIDL_COMMON_FAVORITES 0x001f

#ifndef _SHFOLDER_H_
#define CSIDL_INTERNET_CACHE 0x0020
#define CSIDL_COOKIES 0x0021
#define CSIDL_HISTORY 0x0022
#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_MYPICTURES 0x0027 // C:\Program Files\My Pictures
#endif // _SHFOLDER_H_

#define CSIDL_PROFILE 0x0028 // USERPROFILE
#define CSIDL_SYSTEMX86 0x0029 // x86 system directory on RISC
#define CSIDL_PROGRAM_FILESX86 0x002a // x86 C:\Program Files on RISC

#ifndef _SHFOLDER_H_
#define CSIDL_PROGRAM_FILES_COMMON 0x002b // C:\Program Files\Common
#endif // _SHFOLDER_H_

#define CSIDL_PROGRAM_FILES_COMMONX86 0x002c // x86 Program Files\Common on RISC
#define CSIDL_COMMON_TEMPLATES 0x002d // All Users\Templates

#ifndef _SHFOLDER_H_
#define CSIDL_COMMON_DOCUMENTS 0x002e // All Users\Documents
#define CSIDL_COMMON_ADMINTOOLS 0x002f // All Users\Start Menu\Programs\Administrative Tools
#define CSIDL_ADMINTOOLS 0x0030 // <user name>\Start Menu\Programs\Administrative Tools
#endif // _SHFOLDER_H_

#define CSIDL_CONNECTIONS 0x0031 // Network and Dial-up Connections
#define CSIDL_COMMON_MUSIC 0x0035 // All Users\My Music
#define CSIDL_COMMON_PICTURES 0x0036 // All Users\My Pictures
#define CSIDL_COMMON_VIDEO 0x0037 // All Users\My Video
#define CSIDL_RESOURCES 0x0038 // Resource Direcotry

#ifndef _SHFOLDER_H_
#define CSIDL_RESOURCES_LOCALIZED 0x0039 // Localized Resource Direcotry
#endif // _SHFOLDER_H_

#define CSIDL_COMPUTERSNEARME 0x003d // Computers Near Me (computered from Workgroup membership)



O, como bien explica Carlos:

Code: Select all  Expand view

? GetEnv( "ProgramData" )       //=C:\ProgramData
? GetEnv( "ProgramFiles" )      //=C:\Program Files
? GetEnv( "ProgramFiles(x86)" ) //=C:\Program Files (x86)
? GetEnv( "ProgramW6432" )      //=C:\Program Files
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6501
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 26 guests