How to retrieve the System name

  • 19 years ago

    From Vb i want to retrieve the system and store it in a variable.
    so pls give solution how to get the system name from VB

  • 19 years ago

    You mean the name of the computer? Try the GetComputerName API

  • 19 years ago

    Hi James
    can you explain more detail
    about retrieve sistem name from computer


  • 19 years ago

    Code:
    Private Declare Function apiGetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long


    Private Function GetPCName() As String
    Dim sResult As String
        '// Computer Name
        '// Fill the buffer with the maximum length (255 characters)
        sResult = Space(255)
        '// Call the API function
        Call apiGetComputerName(sResult, 255)
        '// Get the returned value, stripping off any trailing null characters
        '// lPos contains the length of the computer name
        GetPCName =StripTerminator(sResult)
    End Sub


    Private Function StripTerminator(sString As String) As String
        StripTerminator = Left$(sString, InStr(sString, Chr$(0)) - 1)
    End Function

  • 19 years ago

    Hi James i have one more question
    can you tell me how to get computer IP address,
    Domain, and etc. it is same way like get computer name?
    plsss james

  • 19 years ago

    Nope... it's different. There is some info here. (scroll down to the IP address section)

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The greatest performance improvement of all is when a system goes from not-working to working.” - John Ousterhout