Declare for userprofile directory

  • Thread starter Thread starter Joshua A. Booker
  • Start date Start date
J

Joshua A. Booker

Hi,

I'd like to return the location of a user's profile directory.
(ie:"C:\Documents and Settings\...") Does anyone have an api declare
statement that exposes a function for this?

TIA,
Josh
 
Nevermind...I found it:

Declare Function GetEnvironmentVariable Lib "kernel32" Alias
"GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpBuffer As String,
nSize As Long) As Long

Function GetUserProfile() As String

Dim ls_UserprofileDir As String
Dim ll_l As Long

ls_UserprofileDir = Space(255)
ll_l = 255
ll_l = GetEnvironmentVariable("USERPROFILE", ls_UserprofileDir, ll_l)
ls_UserprofileDir = Trim(Left(ls_UserprofileDir, ll_l))
GetUserProfile = ls_UserprofileDir

End Function
 
Back
Top