Results 1 to 5 of 5

Thread: Computer Name [Resolved]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2003
    Location
    IL
    Posts
    739

    Computer Name [Resolved]

    Does anyone know how to get the computer name off the current machine? I will need to be able to do this on Win 98, 2000, and XP if the method is different for each one.
    Last edited by Maldrid; Aug 14th, 2003 at 10:13 AM.
    Motto: Anything for a laugh.

    Getting second place only means you are the first loser to cross the finish line.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Via the AllApi.Net guide

    says it works on 95 and up
    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
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Ther codebank forum has a good example of this. Try a search there - this post has been answered 60+ times in the past year.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2003
    Location
    IL
    Posts
    739
    Yea I tried doing a search for Computer Name, but then I get every post that has computer in it. Do you know how many posts that is?
    Motto: Anything for a laugh.

    Getting second place only means you are the first loser to cross the finish line.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2003
    Location
    IL
    Posts
    739
    Thanks kleinma. I should of checked the API guide myself hehe, but my first instincts is to always go here.
    Motto: Anything for a laugh.

    Getting second place only means you are the first loser to cross the finish line.

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