Resulta que estoy haciendo un programa que hace backups de cierta infomacion y necesitaba obtener (mediante Environ) algo asi:
En windows 7: C:\Users\<Usuario>\AppData\Local\
En windows XP: C:\Documents And Settings\<Usuario>\Configuracion Local\Datos de programa\
Para windows vista y adelante existe la variable de entorno "LocalAppData" pero para windows Xp no, y no encontre forma de hacerlo mediante Environ, hasta que buscando encontre un codigo en VBS, lo que facilmente lo pase a esta funcion:
Código
' Version original xD Public Function GetLocalAppData() As String GetLocalAppData = CreateObject("Shell.Application").NameSpace(28).Self.Path End Function
Funciona en windows 2000 en adelante
FUENTE original: http://www.winhelponline.com/blog/add-localappdata-environment-variable-in-windows-xp/ (Ver los comentarios)
EDIT! V2
Bueno, me pico la curiosidad y fui mas alla! jeje, deje el createObject y uso API ahora asi que bueno, hice esta pequeña Extension de Environ llamada "EnvironEx" que comparando resultados queda
Environ que te devuelve estos resulatdos
Citar
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\User\AppData\Roaming
CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=RAUL-PC
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Raul
LOCALAPPDATA=C:\Users\User\AppData\Local
LOGONSERVER=\\RAUL-PC
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=...................................
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 2, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f02
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\User\AppData\Local\Temp
TMP=C:\Users\User\AppData\Local\Temp
USERDOMAIN=Raul-PC
USERNAME=User
USERPROFILE=C:\Users\User
windir=C:\Windows
APPDATA=C:\Users\User\AppData\Roaming
CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=RAUL-PC
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Raul
LOCALAPPDATA=C:\Users\User\AppData\Local
LOGONSERVER=\\RAUL-PC
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=...................................
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 2, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f02
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\User\AppData\Local\Temp
TMP=C:\Users\User\AppData\Local\Temp
USERDOMAIN=Raul-PC
USERNAME=User
USERPROFILE=C:\Users\User
windir=C:\Windows
Comparando con los comentarios que estan al lado de cada constante. Como veran, hay info que hay en uno que en otro no hay...
Código
Option Explicit ' Los resultados que tiro con windows 7 Public Enum CSIDL CSIDL_PROFILE = 40 ' C:\Users\Raul CSIDL_PERSONAL = 5 ' C:\Users\Raul\Documents CSIDL_DESKTOP = 0 ' C:\Users\Raul\Desktop CSIDL_DESKTOPDIRECTORY = 16 ' C:\Users\Raul\Desktop CSIDL_FAVORITES = 6 ' C:\Users\Raul\Favorites CSIDL_MYMUSIC = 13 ' C:\Users\Raul\Music CSIDL_MYPICTURES = 39 ' C:\Users\Raul\Pictures CSIDL_MYVIDEO = 14 ' C:\Users\Raul\Videos CSIDL_LOCAL_APPDATA = 28 ' C:\Users\Raul\AppData\Local CSIDL_HISTORY = 34 ' C:\Users\Raul\AppData\Local\Microsoft\Windows\History CSIDL_INTERNET_CACHE = 32 ' C:\Users\Raul\AppData\Local\Microsoft\Windows\Temporary Internet Files CSIDL_APPDATA = 26 ' C:\Users\Raul\AppData\Roaming CSIDL_RECENT = 8 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Recent CSIDL_SENDTO = 9 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\SendTo CSIDL_TEMPLATES = 21 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Templates CSIDL_NETHOOD = 19 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Network Shortcuts CSIDL_PRINTHOOD = 27 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Printer Shortcuts CSIDL_COOKIES = 33 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Cookies CSIDL_STARTMENU = 11 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Start Menu CSIDL_STARTUP = 7 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup CSIDL_PROGRAMS = 2 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Start Menu\Programs CSIDL_ADMINTOOLS = 48 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools CSIDL_ALTSTARTUP = 29 ' C:\Users\Raul\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup CSIDL_CDBURN_AREA = 59 ' C:\Users\Raul\AppData\Local\Microsoft\Windows\Burn\Burn CSIDL_COMMON_APPDATA = 35 ' C:\ProgramData CSIDL_COMMON_ADMINTOOLS = 47 ' C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools CSIDL_COMMON_ALTSTARTUP = 30 ' C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup CSIDL_COMMON_STARTMENU = 22 ' C:\ProgramData\Microsoft\Windows\Start Menu CSIDL_COMMON_PROGRAMS = 23 ' C:\ProgramData\Microsoft\Windows\Start Menu\Programs CSIDL_COMMON_STARTUP = 24 ' C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup CSIDL_COMMON_TEMPLATES = 45 ' C:\ProgramData\Microsoft\Windows\Templates CSIDL_COMMON_OEM_LINKS = 58 ' C:\ProgramData\OEM Links CSIDL_COMMON_DESKTOPDIRECTORY = 25 ' C:\Users\Public\Desktop CSIDL_COMMON_DOCUMENTS = 46 ' C:\Users\Public\Documents CSIDL_COMMON_FAVORITES = 31 ' C:\Users\Raul\Favorites CSIDL_COMMON_MUSIC = 53 ' C:\Users\Public\Music CSIDL_COMMON_PICTURES = 54 ' C:\Users\Public\Pictures CSIDL_COMMON_VIDEO = 55 ' C:\Users\Public\Videos CSIDL_BITBUCKET = 10 ' ??? CSIDL_COMPUTERSNEARME = 61 ' ??? CSIDL_CONNECTIONS = 49 ' ??? CSIDL_CONTROLS = 3 ' ??? CSIDL_DRIVES = 17 ' ??? CSIDL_INTERNET = 1 ' ??? CSIDL_MYDOCUMENTS = 12 ' ??? CSIDL_NETWORK = 18 ' ??? CSIDL_PRINTERS = 4 ' ??? CSIDL_FONTS = 20 ' C:\Windows\Fonts CSIDL_PROGRAM_FILES = 38 ' C:\Program Files CSIDL_PROGRAM_FILESX86 = 42 ' C:\Program Files CSIDL_PROGRAM_FILES_COMMON = 43 ' C:\Program Files\Common Files CSIDL_PROGRAM_FILES_COMMONX86 = 44 ' C:\Program Files\Common Files CSIDL_RESOURCES = 56 ' C:\Windows\resources CSIDL_RESOURCES_LOCALIZED = 57 ' C:\Windows\resources\0c0a CSIDL_SYSTEM = 37 ' C:\Windows\system32 CSIDL_SYSTEMX86 = 41 ' C:\Windows\system32 CSIDL_WINDOWS = 36 ' C:\Windows End Enum Private Declare Function SHGetFolderPath Lib "shfolder" _ Alias "SHGetFolderPathA" _ (ByVal hwndOwner As Long, ByVal nFolder As Long, _ ByVal hToken As Long, ByVal dwFlags As Long, _ ByVal pszPath As String) As Long Private Const MAX_PATH = 260 Public Function EnvironEx(nCode As CSIDL) As String Dim path As String * MAX_PATH Call SHGetFolderPath(&H0, nCode, 0, 0, path) EnvironEx = Replace$(Trim$(path), vbNullChar, vbNullString) End Function
Y ahora si, es un aporte esto ya (No descubri nada del otro mundo, simplemente lo comparto porque seguro hay quienes no sabian de la existencia de esto)