Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Enum COMPUTER_NAME_FORMAT As Integer
- ComputerNameNetBIOS = 0
- ComputerNameDnsHostname = 1
- ComputerNameDnsDomain = 2
- ComputerNameDnsFullyQualified = 3
- ComputerNamePhysicalNetBIOS = 4
- ComputerNamePhysicalDnsHostname = 5
- ComputerNamePhysicalDnsDomain = 6
- ComputerNamePhysicalDnsFullyQualified = 7
- End Enum
- Public Const MAX_COMPUTERNAME_LENGTH As Int32 = 31
- <DllImport("kernel32.dll", CharSet:=CharSet.Ansi, SetLastError:=True)> _
- Private Shared Function SetComputerNameEx( _
- ByVal NameType As COMPUTER_NAME_FORMAT, _
- <MarshalAs(UnmanagedType.LPStr)> ByVal lpBuffer As String) As Integer
- End Function
- Public Function SetNewName(ByVal Computername As String) As Boolean
- If NetworkSet.SetComputerNameEx(COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsHostname, _
- Computername & Convert.ToChar(0)) = 0 Then
- Throw New Win32Exception
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement