Results 1 to 3 of 3

Thread: Computer Name

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    688

    Computer Name

    Hi

    How we can get Computer Name

    Thanks

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Computer Name

    Code:
    Private Declare Function GetComputerNameW Lib "kernel32.dll" (ByVal lpBuffer As Long, ByRef lpnSize As Long) As Long
    
    Public Function GetComputerName() As String
        Const MAX_COMPUTERNAME_LENGTH = 31&
        Dim nSize As Long, sBuffer As String
    
        nSize = MAX_COMPUTERNAME_LENGTH
        sBuffer = Space$(nSize)
        If GetComputerNameW(StrPtr(sBuffer), nSize) Then GetComputerName = Left$(sBuffer, nSize)
    End Function
    Don't forget to mark this thread Resolved if you're done!
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Computer Name

    Also...
    You could use vb6 Environ function
    Code:
        'displays Computer name
        MsgBox Environ("ComputerName")
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

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