Results 1 to 40 of 85

Thread: Visual Basic API FAQs

Threaded View

  1. #11
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Get the name of the current user, and the computer
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, _
    4.                                                                               nSize As Long) _
    5.                                                                               As Long
    6. Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, _
    7.                                                                                   nSize As Long) _
    8.                                                                                   As Long
    9.  
    10.  
    11. Private Function ReturnUserName() As String
    12.  
    13.     ReturnUserName = Space$(255)
    14.     Call GetUserName(ReturnUserName, Len(ReturnUserName))
    15.  
    16. End Function
    17.  
    18. Private Function ReturnComputerName() As String
    19.  
    20.     ReturnComputerName = Space$(255)
    21.     Call GetComputerName(ReturnComputerName, Len(ReturnComputerName))
    22.  
    23. End Function
    24.  
    25. Private Sub Command1_Click()
    26.  
    27.     MsgBox ReturnUserName
    28.     MsgBox ReturnComputerName
    29.    
    30. End Sub

    Last edited by crptcblade; Nov 13th, 2002 at 10:45 PM.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width