|
|
Title | Find the user's profile path |
Description | This example shows how to find the user's profile path in Visual Basic 6. It uses the GetUserName and GetWindowsDirectory API functions. |
Keywords | profile path, GetUserName, GetWindowsDirectory |
Categories | Windows, Files and Directories |
|
|
Function ProfilePath concatenates the results of the GetWindowsDirectory and GetUserName API functions.
|
|
' Return the user's profile path.
Private Function ProfilePath() As String
Dim win_dir As String
Dim user_name As String
Dim ret_len As Long
' Get the windows directory.
win_dir = Space$(256)
ret_len = GetWindowsDirectory(win_dir, Len(win_dir))
win_dir = Left$(win_dir, ret_len)
' Get the user's name.
user_name = Space$(256)
GetUserName user_name, ret_len
user_name = Left$(user_name, ret_len)
ProfilePath = win_dir & "\" & user_name
End Function
|
|
 |
|
|
|