Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than kernel32, prefix the name with the module name and a period.
<DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Private Shared Function GetComputerNameEx(ByVal NameType As COMPUTER_NAME_FORMAT, ByVal lpBuffer As StringBuilder, ByRef lpnSize As UInt32) As Boolean
End Function
or
<DllImport("kernel32.dll", EntryPoint:="GetComputerNameW", SetLastError:=True)> _
Public Function GetComputerName(<MarshalAs(UnmanagedType.LPTSTR)>sb As System.Text.StringBuilder, _
ByRef length As Integer) As <MarshalAs(UnmanagedType.Bool)>Boolean
End function
Notes:
None.
VB Signature:
Declare Function GetComputerName Lib "kernel32" (ByVal lpBuffer As String, ByRef nMax As Integer) As Boolean
Tips & Tricks:
Please add some!
User-Defined Types:
None.
Sample Code:
Please add some!
Notes:
The GetComputerName function retrieves the NetBIOS name of the local computer. This name is established at system startup, when the system reads it from the registry.
Public Class Class1
<DllImport("kernel32.dll", EntryPoint:="GetComputerNameW", SetLastError:=True)> _
Public Function GetComputerName(<MarshalAs(UnmanagedType.LPTSTR)>sb As System.Text.StringBuilder, _
ByRef length As Integer) As <MarshalAs(UnmanagedType.Bool)>Boolean
End function
<STAThread> _
Public Sub Main()
Dim buffer As System.Text.StringBuilder
buffer = new System.Text.StringBuilder(512)
Dim Size as Integer = buffer.Length
GetComputerName(buffer, Size)
System.Console.WriteLine(buffer.ToString()))
End Sub
End Class
Sample Code (VB):
Dim buff As String = Space(255)
Dim max As Integer = 255
Dim rc As Integer
rc = GetComputerName(buff,max)
' Now, max contains the total number of characters written to the buffer
MessageBox.Show( Mid(buff,1,max) )
Alternative Managed API:
System.Environment.MachineName will get you the netbios name.
Declare Unicode Function GetCompName2 Lib "Kernel32" Alias "GetComputerNameA" (ByVal Puffer As StringBuilder, ByRef Laenge As IntPtr) As Integer
Sub Main()
Dim CompName As New StringBuilder()
Dim Ret As Integer
'Ret = GetComputerNameAlt(CompName, 100)
Ret = GetCompName2(CompName, 100)
Dim CompNameBytes() As Byte = Encoding.Unicode.GetBytes(CompName.ToString)
Dim CompNameStr As String = Encoding.Default.GetString(CompNameBytes)
Console.WriteLine("Der Computer heißt: {0}", CompNameStr)
Console.ReadLine()
End Sub
The Netbios function interprets and executes the specified network control block (NCB). The Netbios function is provided primarily for applications that were written for the NetBIOS interface and need to be ported to Windows. Applications not requiring compatibility with NetBIOS should use other interfaces, such as mailslots, named pipes, RPC, or distributed COM to accomplish tasks similar to those supported by NetBIOS. These other interfaces are more flexible and portable.
5/23/2014 9:41:50 AM - jonr@reedholm.com-71.114.254.154
Retrieves a NetBIOS or DNS name associated with the local computer.
6/26/2021 4:19:39 AM - dauth-202.166.147.204
Values that specify a type of computer name, as in GetComputerNameEx and SetComputerNameEx.
3/16/2007 7:40:36 AM - anonymous
Retrieves a NetBIOS or DNS name associated with the local computer.
6/26/2021 4:19:39 AM - dauth-202.166.147.204
The Netbios function interprets and executes the specified network control block (NCB). The Netbios function is provided primarily for applications that were written for the NetBIOS interface and need to be ported to Windows. Applications not requiring compatibility with NetBIOS should use other interfaces, such as mailslots, named pipes, RPC, or distributed COM to accomplish tasks similar to those supported by NetBIOS. These other interfaces are more flexible and portable.
5/23/2014 9:41:50 AM - jonr@reedholm.com-71.114.254.154
Click to read this page
4/6/2008 7:23:14 AM - anonymous
TODO - a short description
3/16/2007 7:31:57 AM - anfortas.geo@yahoo.com-216.204.61.86
The SetLastError API
1/26/2016 3:27:33 AM - -124.148.167.58
ByVal is a VB keyword that specifies a variable to be passed as a parameter BY VALUE. In other words, if the function or sub changes the value of the internal variable, it does not change the value of the external variable that was passed to it.
4/25/2007 3:19:55 AM - josep1er@cmich.edu-141.209.229.179
Click to read this page
10/2/2011 2:35:57 AM - txzhgh-89.110.151.174
ByVal is a VB keyword that specifies a variable to be passed as a parameter BY VALUE. In other words, if the function or sub changes the value of the internal variable, it does not change the value of the external variable that was passed to it.
4/25/2007 3:19:55 AM - josep1er@cmich.edu-141.209.229.179
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).