ホーム › System.HostComputeNetwork › HcnCreateNamespace
HcnCreateNamespace
関数新しいネットワーク名前空間を作成する。
シグネチャ
// computenetwork.dll
#include <windows.h>
HRESULT HcnCreateNamespace(
const GUID* Id,
LPCWSTR Settings,
void** Namespace,
LPWSTR* ErrorRecord // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Id | GUID* | in |
| Settings | LPCWSTR | in |
| Namespace | void** | out |
| ErrorRecord | LPWSTR* | outoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// computenetwork.dll
#include <windows.h>
HRESULT HcnCreateNamespace(
const GUID* Id,
LPCWSTR Settings,
void** Namespace,
LPWSTR* ErrorRecord // optional
);[DllImport("computenetwork.dll", ExactSpelling = true)]
static extern int HcnCreateNamespace(
ref Guid Id, // GUID*
[MarshalAs(UnmanagedType.LPWStr)] string Settings, // LPCWSTR
IntPtr Namespace, // void** out
IntPtr ErrorRecord // LPWSTR* optional, out
);<DllImport("computenetwork.dll", ExactSpelling:=True)>
Public Shared Function HcnCreateNamespace(
ByRef Id As Guid, ' GUID*
<MarshalAs(UnmanagedType.LPWStr)> Settings As String, ' LPCWSTR
[Namespace] As IntPtr, ' void** out
ErrorRecord As IntPtr ' LPWSTR* optional, out
) As Integer
End Function' Id : GUID*
' Settings : LPCWSTR
' Namespace : void** out
' ErrorRecord : LPWSTR* optional, out
Declare PtrSafe Function HcnCreateNamespace Lib "computenetwork" ( _
ByVal Id As LongPtr, _
ByVal Settings As LongPtr, _
ByVal Namespace As LongPtr, _
ByVal ErrorRecord As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HcnCreateNamespace = ctypes.windll.computenetwork.HcnCreateNamespace
HcnCreateNamespace.restype = ctypes.c_int
HcnCreateNamespace.argtypes = [
ctypes.c_void_p, # Id : GUID*
wintypes.LPCWSTR, # Settings : LPCWSTR
ctypes.c_void_p, # Namespace : void** out
ctypes.c_void_p, # ErrorRecord : LPWSTR* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computenetwork.dll')
HcnCreateNamespace = Fiddle::Function.new(
lib['HcnCreateNamespace'],
[
Fiddle::TYPE_VOIDP, # Id : GUID*
Fiddle::TYPE_VOIDP, # Settings : LPCWSTR
Fiddle::TYPE_VOIDP, # Namespace : void** out
Fiddle::TYPE_VOIDP, # ErrorRecord : LPWSTR* optional, out
],
Fiddle::TYPE_INT)#[link(name = "computenetwork")]
extern "system" {
fn HcnCreateNamespace(
Id: *const GUID, // GUID*
Settings: *const u16, // LPCWSTR
Namespace: *mut *mut (), // void** out
ErrorRecord: *mut *mut u16 // LPWSTR* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("computenetwork.dll")]
public static extern int HcnCreateNamespace(ref Guid Id, [MarshalAs(UnmanagedType.LPWStr)] string Settings, IntPtr Namespace, IntPtr ErrorRecord);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computenetwork_HcnCreateNamespace' -Namespace Win32 -PassThru
# $api::HcnCreateNamespace(Id, Settings, Namespace, ErrorRecord)#uselib "computenetwork.dll"
#func global HcnCreateNamespace "HcnCreateNamespace" sptr, sptr, sptr, sptr
; HcnCreateNamespace varptr(Id), Settings, Namespace, varptr(ErrorRecord) ; 戻り値は stat
; Id : GUID* -> "sptr"
; Settings : LPCWSTR -> "sptr"
; Namespace : void** out -> "sptr"
; ErrorRecord : LPWSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "computenetwork.dll" #cfunc global HcnCreateNamespace "HcnCreateNamespace" var, wstr, sptr, var ; res = HcnCreateNamespace(Id, Settings, Namespace, ErrorRecord) ; Id : GUID* -> "var" ; Settings : LPCWSTR -> "wstr" ; Namespace : void** out -> "sptr" ; ErrorRecord : LPWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "computenetwork.dll" #cfunc global HcnCreateNamespace "HcnCreateNamespace" sptr, wstr, sptr, sptr ; res = HcnCreateNamespace(varptr(Id), Settings, Namespace, varptr(ErrorRecord)) ; Id : GUID* -> "sptr" ; Settings : LPCWSTR -> "wstr" ; Namespace : void** out -> "sptr" ; ErrorRecord : LPWSTR* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT HcnCreateNamespace(GUID* Id, LPCWSTR Settings, void** Namespace, LPWSTR* ErrorRecord) #uselib "computenetwork.dll" #cfunc global HcnCreateNamespace "HcnCreateNamespace" var, wstr, intptr, var ; res = HcnCreateNamespace(Id, Settings, Namespace, ErrorRecord) ; Id : GUID* -> "var" ; Settings : LPCWSTR -> "wstr" ; Namespace : void** out -> "intptr" ; ErrorRecord : LPWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT HcnCreateNamespace(GUID* Id, LPCWSTR Settings, void** Namespace, LPWSTR* ErrorRecord) #uselib "computenetwork.dll" #cfunc global HcnCreateNamespace "HcnCreateNamespace" intptr, wstr, intptr, intptr ; res = HcnCreateNamespace(varptr(Id), Settings, Namespace, varptr(ErrorRecord)) ; Id : GUID* -> "intptr" ; Settings : LPCWSTR -> "wstr" ; Namespace : void** out -> "intptr" ; ErrorRecord : LPWSTR* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computenetwork = windows.NewLazySystemDLL("computenetwork.dll")
procHcnCreateNamespace = computenetwork.NewProc("HcnCreateNamespace")
)
// Id (GUID*), Settings (LPCWSTR), Namespace (void** out), ErrorRecord (LPWSTR* optional, out)
r1, _, err := procHcnCreateNamespace.Call(
uintptr(Id),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Settings))),
uintptr(Namespace),
uintptr(ErrorRecord),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcnCreateNamespace(
Id: PGUID; // GUID*
Settings: PWideChar; // LPCWSTR
Namespace: Pointer; // void** out
ErrorRecord: PPWideChar // LPWSTR* optional, out
): Integer; stdcall;
external 'computenetwork.dll' name 'HcnCreateNamespace';result := DllCall("computenetwork\HcnCreateNamespace"
, "Ptr", Id ; GUID*
, "WStr", Settings ; LPCWSTR
, "Ptr", Namespace ; void** out
, "Ptr", ErrorRecord ; LPWSTR* optional, out
, "Int") ; return: HRESULT●HcnCreateNamespace(Id, Settings, Namespace, ErrorRecord) = DLL("computenetwork.dll", "int HcnCreateNamespace(void*, char*, void*, void*)")
# 呼び出し: HcnCreateNamespace(Id, Settings, Namespace, ErrorRecord)
# Id : GUID* -> "void*"
# Settings : LPCWSTR -> "char*"
# Namespace : void** out -> "void*"
# ErrorRecord : LPWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。