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
$signature = @"
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace Test_Namespace{
public enum COMPUTER_NAME_FORMAT
{
ComputerNameNetBIOS,
ComputerNameDnsHostname,
ComputerNameDnsDomain,
ComputerNameDnsFullyQualified,
ComputerNamePhysicalNetBIOS,
ComputerNamePhysicalDnsHostname,
ComputerNamePhysicalDnsDomain,
ComputerNamePhysicalDnsFullyQualified
}
public class Test_class{
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
public static extern bool GetComputerNameEx(COMPUTER_NAME_FORMAT NameType,
StringBuilder lpBuffer, ref uint lpnSize);
}
}
"@
Add-Type -TypeDefinition $signature -PassThru
$size = 64
# way 2 to declare string builder
$str_builder_obj = [System.Text.StringBuilder]::new($size)
# run the method
[Test_Namespace.Test_class]::GetComputerNameEx([Test_Namespace.COMPUTER_NAME_FORMAT]::ComputerNameDnsDomain, $str_builder_obj, [ref]$size)
# view the contents
$str_builder_obj.ToString()
Alternative Managed API:
Do you know one? Please contribute it!
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
Values that specify a type of computer name, as in GetComputerNameEx and SetComputerNameEx.
3/16/2007 7:40:36 AM - anonymous
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).