Results 1 to 3 of 3

Thread: [RESOLVED] Reading Computer's Name

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    57

    Resolved [RESOLVED] Reading Computer's Name

    I'm trying to get my program to read the name of the computer it is running on and output it to Text1. Not sure how to do this.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Reading Computer's Name

    Use the API
    VB Code:
    1. 'example by Donavon Kuhn ([email protected])
    2. Private Const MAX_COMPUTERNAME_LENGTH As Long = 31
    3. Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    4. Private Sub Form_Load()
    5.     Dim dwLen As Long
    6.     Dim strString As String
    7.     'Create a buffer
    8.     dwLen = MAX_COMPUTERNAME_LENGTH + 1
    9.     strString = String(dwLen, "X")
    10.     'Get the computer name
    11.     GetComputerName strString, dwLen
    12.     'get only the actual data
    13.     strString = Left(strString, dwLen)
    14.     'Show the computer name
    15.     MsgBox strString
    16. End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    57

    Re: Reading Computer's Name

    thanks

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