Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Get computer name in VB6

Get computer name in VB6

Scheduled Pinned Locked Moved Visual Basic
question
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rulle
    wrote on last edited by
    #1

    What's the function to get the local computer name in VB6? Have a good one!

    A N G R 4 Replies Last reply
    0
    • R Rulle

      What's the function to get the local computer name in VB6? Have a good one!

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      There is none, but you can import GetComputerName from the windows API

      1 Reply Last reply
      0
      • R Rulle

        What's the function to get the local computer name in VB6? Have a good one!

        N Offline
        N Offline
        Nick Parker
        wrote on last edited by
        #3

        You will need this in a module:

        Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

        Then in your code:

        Dim compname As String, retval As Long
        compname = Space(255)
        retval = GetComputerName(compname, 255)
        compname = Left(compname, InStr(compname, vbNullChar) - 1)

        HTH Nick Parker


        1 Reply Last reply
        0
        • R Rulle

          What's the function to get the local computer name in VB6? Have a good one!

          G Offline
          G Offline
          Gautam Panemangalore
          wrote on last edited by
          #4

          I have a code which is less complex you will have to import import system.net.dns Sample code is as follows: Imports System.Net.Dns Dim shostname As String shostname = system.Net.DNS.GetHostName() console.writeline("Your Machine Name = " & shostname) hope that helps

          L 1 Reply Last reply
          0
          • G Gautam Panemangalore

            I have a code which is less complex you will have to import import system.net.dns Sample code is as follows: Imports System.Net.Dns Dim shostname As String shostname = system.Net.DNS.GetHostName() console.writeline("Your Machine Name = " & shostname) hope that helps

            L Offline
            L Offline
            Lasse
            wrote on last edited by
            #5

            This is not possible i VB6.. Hmm...

            G 1 Reply Last reply
            0
            • L Lasse

              This is not possible i VB6.. Hmm...

              G Offline
              G Offline
              Gautam Panemangalore
              wrote on last edited by
              #6

              ohh you are right thats possible in VB.NET

              1 Reply Last reply
              0
              • R Rulle

                What's the function to get the local computer name in VB6? Have a good one!

                R Offline
                R Offline
                Rulle
                wrote on last edited by
                #7

                Nick parker's code works perfectly! Thank you all! /Rulle

                N 1 Reply Last reply
                0
                • R Rulle

                  Nick parker's code works perfectly! Thank you all! /Rulle

                  N Offline
                  N Offline
                  Nick Parker
                  wrote on last edited by
                  #8

                  No Problem, you should consider becoming a member. :) Nick Parker


                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups