Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleFind the user's profile path
DescriptionThis example shows how to find the user's profile path in Visual Basic 6. It uses the GetUserName and GetWindowsDirectory API functions.
Keywordsprofile path, GetUserName, GetWindowsDirectory
CategoriesWindows, 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated