ホーム › NetworkManagement.NetManagement › NetServerComputerNameAdd
NetServerComputerNameAdd
関数サーバーにエミュレートするコンピューター名を追加する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetServerComputerNameAdd(
LPWSTR ServerName, // optional
LPWSTR EmulatedDomainName, // optional
LPWSTR EmulatedServerName
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerName | LPWSTR | inoptional |
| EmulatedDomainName | LPWSTR | inoptional |
| EmulatedServerName | LPWSTR | in |
戻り値の型: DWORD
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
DWORD NetServerComputerNameAdd(
LPWSTR ServerName, // optional
LPWSTR EmulatedDomainName, // optional
LPWSTR EmulatedServerName
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetServerComputerNameAdd(
[MarshalAs(UnmanagedType.LPWStr)] string ServerName, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string EmulatedDomainName, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string EmulatedServerName // LPWSTR
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetServerComputerNameAdd(
<MarshalAs(UnmanagedType.LPWStr)> ServerName As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> EmulatedDomainName As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> EmulatedServerName As String ' LPWSTR
) As UInteger
End Function' ServerName : LPWSTR optional
' EmulatedDomainName : LPWSTR optional
' EmulatedServerName : LPWSTR
Declare PtrSafe Function NetServerComputerNameAdd Lib "netapi32" ( _
ByVal ServerName As LongPtr, _
ByVal EmulatedDomainName As LongPtr, _
ByVal EmulatedServerName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NetServerComputerNameAdd = ctypes.windll.netapi32.NetServerComputerNameAdd
NetServerComputerNameAdd.restype = wintypes.DWORD
NetServerComputerNameAdd.argtypes = [
wintypes.LPCWSTR, # ServerName : LPWSTR optional
wintypes.LPCWSTR, # EmulatedDomainName : LPWSTR optional
wintypes.LPCWSTR, # EmulatedServerName : LPWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
NetServerComputerNameAdd = Fiddle::Function.new(
lib['NetServerComputerNameAdd'],
[
Fiddle::TYPE_VOIDP, # ServerName : LPWSTR optional
Fiddle::TYPE_VOIDP, # EmulatedDomainName : LPWSTR optional
Fiddle::TYPE_VOIDP, # EmulatedServerName : LPWSTR
],
-Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn NetServerComputerNameAdd(
ServerName: *mut u16, // LPWSTR optional
EmulatedDomainName: *mut u16, // LPWSTR optional
EmulatedServerName: *mut u16 // LPWSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetServerComputerNameAdd([MarshalAs(UnmanagedType.LPWStr)] string ServerName, [MarshalAs(UnmanagedType.LPWStr)] string EmulatedDomainName, [MarshalAs(UnmanagedType.LPWStr)] string EmulatedServerName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetServerComputerNameAdd' -Namespace Win32 -PassThru
# $api::NetServerComputerNameAdd(ServerName, EmulatedDomainName, EmulatedServerName)#uselib "NETAPI32.dll"
#func global NetServerComputerNameAdd "NetServerComputerNameAdd" sptr, sptr, sptr
; NetServerComputerNameAdd ServerName, EmulatedDomainName, EmulatedServerName ; 戻り値は stat
; ServerName : LPWSTR optional -> "sptr"
; EmulatedDomainName : LPWSTR optional -> "sptr"
; EmulatedServerName : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "NETAPI32.dll"
#cfunc global NetServerComputerNameAdd "NetServerComputerNameAdd" wstr, wstr, wstr
; res = NetServerComputerNameAdd(ServerName, EmulatedDomainName, EmulatedServerName)
; ServerName : LPWSTR optional -> "wstr"
; EmulatedDomainName : LPWSTR optional -> "wstr"
; EmulatedServerName : LPWSTR -> "wstr"; DWORD NetServerComputerNameAdd(LPWSTR ServerName, LPWSTR EmulatedDomainName, LPWSTR EmulatedServerName)
#uselib "NETAPI32.dll"
#cfunc global NetServerComputerNameAdd "NetServerComputerNameAdd" wstr, wstr, wstr
; res = NetServerComputerNameAdd(ServerName, EmulatedDomainName, EmulatedServerName)
; ServerName : LPWSTR optional -> "wstr"
; EmulatedDomainName : LPWSTR optional -> "wstr"
; EmulatedServerName : LPWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procNetServerComputerNameAdd = netapi32.NewProc("NetServerComputerNameAdd")
)
// ServerName (LPWSTR optional), EmulatedDomainName (LPWSTR optional), EmulatedServerName (LPWSTR)
r1, _, err := procNetServerComputerNameAdd.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(EmulatedDomainName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(EmulatedServerName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction NetServerComputerNameAdd(
ServerName: PWideChar; // LPWSTR optional
EmulatedDomainName: PWideChar; // LPWSTR optional
EmulatedServerName: PWideChar // LPWSTR
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetServerComputerNameAdd';result := DllCall("NETAPI32\NetServerComputerNameAdd"
, "WStr", ServerName ; LPWSTR optional
, "WStr", EmulatedDomainName ; LPWSTR optional
, "WStr", EmulatedServerName ; LPWSTR
, "UInt") ; return: DWORD●NetServerComputerNameAdd(ServerName, EmulatedDomainName, EmulatedServerName) = DLL("NETAPI32.dll", "dword NetServerComputerNameAdd(char*, char*, char*)")
# 呼び出し: NetServerComputerNameAdd(ServerName, EmulatedDomainName, EmulatedServerName)
# ServerName : LPWSTR optional -> "char*"
# EmulatedDomainName : LPWSTR optional -> "char*"
# EmulatedServerName : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。