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