Declare Function GetComputerName Lib "kernel32" (ByVal lpBuffer As String, ByRef nMax As Integer) As Boolean
User-Defined Types:
None.
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.
Tips & Tricks:
Make sure to go in to the build properties of your project and check "Allow Unsafe Code". Second version doesn't recquest this.
Sample Code:
using System.Management;
using System.Runtime.InteropServices;
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 GetComputerName API
24/08/2007 11:53:16 - -145.253.232.130
The GetComputerName API
24/08/2007 11:53:16 - -145.253.232.130
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.
08/04/2009 09:19:22 - -77.20.106.17
Click to read this page
06/04/2008 14:23:14 - hlidftvbgb-88.114.46.202
TODO - a short description
16/03/2007 13:31:57 - 66.194.55.242
The SetLastError API
16/03/2007 13:58:10 - -70.224.71.10
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.
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.
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).
NEW: SmartAssembly 5.0
Automated Error Reporting: get a volume of crash reports and a complete state of your program whenever it fails, and improve the quality of your program.