2011-06-06 6 views

Répondre

7

Je crois qu'il ya quelque chose comme

Environ("Username")

+2

+1 ... même si cela ne répond que X d'un (http://www.perlmonks.org/index.pl?node_id=542341) [problème XY] –

9

Vous n'avez pas besoin nom d'utilisateur pour savoir quel dossier est le dossier de données application. Vous devez utiliser la fonction SHGetFolderPath avec la valeur CSIDL_APPDATA.

Private Declare Function SHGetFolderPath Lib "shell32.dll" Alias "SHGetFolderPathA" (ByVal hwnd As Long, ByVal csidl As Long, ByVal hToken As Long, ByVal dwFlags As Long, ByVal pszPath As String) As Long 
Private Const CSIDL_APPDATA As Long = &H1A 
Private Const MAX_PATH As Long = 260 

Dim s As String 
s = String$(MAX_PATH, 0) 

SHGetFolderPath 0, CSIDL_APPDATA, 0, 0, s 

MsgBox Left$(s, InStr(1, s, vbNullChar)) 
Questions connexes