Get Computer name

Source: Internet
Author: User


' Statement GetComputerName
Private Declare Function getcomputername Lib "kernel32" Alias "Getcomputernamea" (ByVal lpbuffer as String, nSize as Long) As Long
' Statement Setcomputername
Private Declare Function setcomputername Lib "kernel32" Alias "Setcomputernamea" (ByVal Lpcomputername as String) as Long
' Define a function to get the computer name
Private Function getcname (ByRef CName) as Boolean
Dim scname as String ' computer name
Dim Lcomputernamelen as Long ' computer name length
Dim LResult as Long ' GetComputerName return value
Dim RV as Boolean ' getcname return value, if TRUE indicates successful operation
Lcomputernamelen = 256
Scname = Space (Lcomputernamelen)
LResult = GetComputerName (Scname, Lcomputernamelen)
If LResult <> 0 Then
CName = left$ (Scname, Lcomputernamelen)
RV = True
Else
RV = False
End If
Getcname = RV
End Function
' Defines a function that modifies a computer's name
Private Function setcname (ByVal CName as String) as Boolean
Dim LResult as Long
Dim RV as Boolean
LResult = Setcomputername (CName)
If LResult <> 0 Then
RV = True ' modification succeeded
Else
RV = False
End If
Setcname = RV
End Function

Get Computer name

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.