ホーム › NetworkManagement.WindowsFirewall › NetworkIsolationDiagnoseConnectFailureAndGetInfo
NetworkIsolationDiagnoseConnectFailureAndGetInfo
関数ネットワーク分離による接続失敗を診断して原因情報を取得する。
シグネチャ
// api-ms-win-net-isolation-l1-1-0.dll
#include <windows.h>
DWORD NetworkIsolationDiagnoseConnectFailureAndGetInfo(
LPCWSTR wszServerName,
NETISO_ERROR_TYPE* netIsoError
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| wszServerName | LPCWSTR | in | 接続診断の対象となるサーバー名のワイド文字列。 |
| netIsoError | NETISO_ERROR_TYPE* | out | 診断結果のネットワーク分離エラー種別を受け取る出力先。 |
戻り値の型: DWORD
各言語での呼び出し定義
// api-ms-win-net-isolation-l1-1-0.dll
#include <windows.h>
DWORD NetworkIsolationDiagnoseConnectFailureAndGetInfo(
LPCWSTR wszServerName,
NETISO_ERROR_TYPE* netIsoError
);[DllImport("api-ms-win-net-isolation-l1-1-0.dll", ExactSpelling = true)]
static extern uint NetworkIsolationDiagnoseConnectFailureAndGetInfo(
[MarshalAs(UnmanagedType.LPWStr)] string wszServerName, // LPCWSTR
out int netIsoError // NETISO_ERROR_TYPE* out
);<DllImport("api-ms-win-net-isolation-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function NetworkIsolationDiagnoseConnectFailureAndGetInfo(
<MarshalAs(UnmanagedType.LPWStr)> wszServerName As String, ' LPCWSTR
<Out> ByRef netIsoError As Integer ' NETISO_ERROR_TYPE* out
) As UInteger
End Function' wszServerName : LPCWSTR
' netIsoError : NETISO_ERROR_TYPE* out
Declare PtrSafe Function NetworkIsolationDiagnoseConnectFailureAndGetInfo Lib "api-ms-win-net-isolation-l1-1-0" ( _
ByVal wszServerName As LongPtr, _
ByRef netIsoError As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NetworkIsolationDiagnoseConnectFailureAndGetInfo = ctypes.windll.LoadLibrary("api-ms-win-net-isolation-l1-1-0.dll").NetworkIsolationDiagnoseConnectFailureAndGetInfo
NetworkIsolationDiagnoseConnectFailureAndGetInfo.restype = wintypes.DWORD
NetworkIsolationDiagnoseConnectFailureAndGetInfo.argtypes = [
wintypes.LPCWSTR, # wszServerName : LPCWSTR
ctypes.c_void_p, # netIsoError : NETISO_ERROR_TYPE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-net-isolation-l1-1-0.dll')
NetworkIsolationDiagnoseConnectFailureAndGetInfo = Fiddle::Function.new(
lib['NetworkIsolationDiagnoseConnectFailureAndGetInfo'],
[
Fiddle::TYPE_VOIDP, # wszServerName : LPCWSTR
Fiddle::TYPE_VOIDP, # netIsoError : NETISO_ERROR_TYPE* out
],
-Fiddle::TYPE_INT)#[link(name = "api-ms-win-net-isolation-l1-1-0")]
extern "system" {
fn NetworkIsolationDiagnoseConnectFailureAndGetInfo(
wszServerName: *const u16, // LPCWSTR
netIsoError: *mut i32 // NETISO_ERROR_TYPE* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-net-isolation-l1-1-0.dll")]
public static extern uint NetworkIsolationDiagnoseConnectFailureAndGetInfo([MarshalAs(UnmanagedType.LPWStr)] string wszServerName, out int netIsoError);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-net-isolation-l1-1-0_NetworkIsolationDiagnoseConnectFailureAndGetInfo' -Namespace Win32 -PassThru
# $api::NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, netIsoError)#uselib "api-ms-win-net-isolation-l1-1-0.dll"
#func global NetworkIsolationDiagnoseConnectFailureAndGetInfo "NetworkIsolationDiagnoseConnectFailureAndGetInfo" sptr, sptr
; NetworkIsolationDiagnoseConnectFailureAndGetInfo wszServerName, varptr(netIsoError) ; 戻り値は stat
; wszServerName : LPCWSTR -> "sptr"
; netIsoError : NETISO_ERROR_TYPE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-net-isolation-l1-1-0.dll" #cfunc global NetworkIsolationDiagnoseConnectFailureAndGetInfo "NetworkIsolationDiagnoseConnectFailureAndGetInfo" wstr, var ; res = NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, netIsoError) ; wszServerName : LPCWSTR -> "wstr" ; netIsoError : NETISO_ERROR_TYPE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-net-isolation-l1-1-0.dll" #cfunc global NetworkIsolationDiagnoseConnectFailureAndGetInfo "NetworkIsolationDiagnoseConnectFailureAndGetInfo" wstr, sptr ; res = NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, varptr(netIsoError)) ; wszServerName : LPCWSTR -> "wstr" ; netIsoError : NETISO_ERROR_TYPE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD NetworkIsolationDiagnoseConnectFailureAndGetInfo(LPCWSTR wszServerName, NETISO_ERROR_TYPE* netIsoError) #uselib "api-ms-win-net-isolation-l1-1-0.dll" #cfunc global NetworkIsolationDiagnoseConnectFailureAndGetInfo "NetworkIsolationDiagnoseConnectFailureAndGetInfo" wstr, var ; res = NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, netIsoError) ; wszServerName : LPCWSTR -> "wstr" ; netIsoError : NETISO_ERROR_TYPE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD NetworkIsolationDiagnoseConnectFailureAndGetInfo(LPCWSTR wszServerName, NETISO_ERROR_TYPE* netIsoError) #uselib "api-ms-win-net-isolation-l1-1-0.dll" #cfunc global NetworkIsolationDiagnoseConnectFailureAndGetInfo "NetworkIsolationDiagnoseConnectFailureAndGetInfo" wstr, intptr ; res = NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, varptr(netIsoError)) ; wszServerName : LPCWSTR -> "wstr" ; netIsoError : NETISO_ERROR_TYPE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_net_isolation_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-net-isolation-l1-1-0.dll")
procNetworkIsolationDiagnoseConnectFailureAndGetInfo = api_ms_win_net_isolation_l1_1_0.NewProc("NetworkIsolationDiagnoseConnectFailureAndGetInfo")
)
// wszServerName (LPCWSTR), netIsoError (NETISO_ERROR_TYPE* out)
r1, _, err := procNetworkIsolationDiagnoseConnectFailureAndGetInfo.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszServerName))),
uintptr(netIsoError),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction NetworkIsolationDiagnoseConnectFailureAndGetInfo(
wszServerName: PWideChar; // LPCWSTR
netIsoError: Pointer // NETISO_ERROR_TYPE* out
): DWORD; stdcall;
external 'api-ms-win-net-isolation-l1-1-0.dll' name 'NetworkIsolationDiagnoseConnectFailureAndGetInfo';result := DllCall("api-ms-win-net-isolation-l1-1-0\NetworkIsolationDiagnoseConnectFailureAndGetInfo"
, "WStr", wszServerName ; LPCWSTR
, "Ptr", netIsoError ; NETISO_ERROR_TYPE* out
, "UInt") ; return: DWORD●NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, netIsoError) = DLL("api-ms-win-net-isolation-l1-1-0.dll", "dword NetworkIsolationDiagnoseConnectFailureAndGetInfo(char*, void*)")
# 呼び出し: NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, netIsoError)
# wszServerName : LPCWSTR -> "char*"
# netIsoError : NETISO_ERROR_TYPE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-net-isolation-l1-1-0" fn NetworkIsolationDiagnoseConnectFailureAndGetInfo(
wszServerName: [*c]const u16, // LPCWSTR
netIsoError: [*c]i32 // NETISO_ERROR_TYPE* out
) callconv(std.os.windows.WINAPI) u32;proc NetworkIsolationDiagnoseConnectFailureAndGetInfo(
wszServerName: WideCString, # LPCWSTR
netIsoError: ptr int32 # NETISO_ERROR_TYPE* out
): uint32 {.importc: "NetworkIsolationDiagnoseConnectFailureAndGetInfo", stdcall, dynlib: "api-ms-win-net-isolation-l1-1-0.dll".}pragma(lib, "api-ms-win-net-isolation-l1-1-0");
extern(Windows)
uint NetworkIsolationDiagnoseConnectFailureAndGetInfo(
const(wchar)* wszServerName, // LPCWSTR
int* netIsoError // NETISO_ERROR_TYPE* out
);ccall((:NetworkIsolationDiagnoseConnectFailureAndGetInfo, "api-ms-win-net-isolation-l1-1-0.dll"), stdcall, UInt32,
(Cwstring, Ptr{Int32}),
wszServerName, netIsoError)
# wszServerName : LPCWSTR -> Cwstring
# netIsoError : NETISO_ERROR_TYPE* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t NetworkIsolationDiagnoseConnectFailureAndGetInfo(
const uint16_t* wszServerName,
int32_t* netIsoError);
]]
local api-ms-win-net-isolation-l1-1-0 = ffi.load("api-ms-win-net-isolation-l1-1-0")
-- api-ms-win-net-isolation-l1-1-0.NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, netIsoError)
-- wszServerName : LPCWSTR
-- netIsoError : NETISO_ERROR_TYPE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-net-isolation-l1-1-0.dll');
const NetworkIsolationDiagnoseConnectFailureAndGetInfo = lib.func('__stdcall', 'NetworkIsolationDiagnoseConnectFailureAndGetInfo', 'uint32_t', ['str16', 'int32_t *']);
// NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, netIsoError)
// wszServerName : LPCWSTR -> 'str16'
// netIsoError : NETISO_ERROR_TYPE* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-net-isolation-l1-1-0.dll", {
NetworkIsolationDiagnoseConnectFailureAndGetInfo: { parameters: ["buffer", "pointer"], result: "u32" },
});
// lib.symbols.NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, netIsoError)
// wszServerName : LPCWSTR -> "buffer"
// netIsoError : NETISO_ERROR_TYPE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t NetworkIsolationDiagnoseConnectFailureAndGetInfo(
const uint16_t* wszServerName,
int32_t* netIsoError);
C, "api-ms-win-net-isolation-l1-1-0.dll");
// $ffi->NetworkIsolationDiagnoseConnectFailureAndGetInfo(wszServerName, netIsoError);
// wszServerName : LPCWSTR
// netIsoError : NETISO_ERROR_TYPE* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Api-ms-win-net-isolation-l1-1-0 extends StdCallLibrary {
Api-ms-win-net-isolation-l1-1-0 INSTANCE = Native.load("api-ms-win-net-isolation-l1-1-0", Api-ms-win-net-isolation-l1-1-0.class);
int NetworkIsolationDiagnoseConnectFailureAndGetInfo(
WString wszServerName, // LPCWSTR
IntByReference netIsoError // NETISO_ERROR_TYPE* out
);
}@[Link("api-ms-win-net-isolation-l1-1-0")]
lib Libapi-ms-win-net-isolation-l1-1-0
fun NetworkIsolationDiagnoseConnectFailureAndGetInfo = NetworkIsolationDiagnoseConnectFailureAndGetInfo(
wszServerName : UInt16*, # LPCWSTR
netIsoError : Int32* # NETISO_ERROR_TYPE* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NetworkIsolationDiagnoseConnectFailureAndGetInfoNative = Uint32 Function(Pointer<Utf16>, Pointer<Int32>);
typedef NetworkIsolationDiagnoseConnectFailureAndGetInfoDart = int Function(Pointer<Utf16>, Pointer<Int32>);
final NetworkIsolationDiagnoseConnectFailureAndGetInfo = DynamicLibrary.open('api-ms-win-net-isolation-l1-1-0.dll')
.lookupFunction<NetworkIsolationDiagnoseConnectFailureAndGetInfoNative, NetworkIsolationDiagnoseConnectFailureAndGetInfoDart>('NetworkIsolationDiagnoseConnectFailureAndGetInfo');
// wszServerName : LPCWSTR -> Pointer<Utf16>
// netIsoError : NETISO_ERROR_TYPE* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NetworkIsolationDiagnoseConnectFailureAndGetInfo(
wszServerName: PWideChar; // LPCWSTR
netIsoError: Pointer // NETISO_ERROR_TYPE* out
): DWORD; stdcall;
external 'api-ms-win-net-isolation-l1-1-0.dll' name 'NetworkIsolationDiagnoseConnectFailureAndGetInfo';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NetworkIsolationDiagnoseConnectFailureAndGetInfo"
c_NetworkIsolationDiagnoseConnectFailureAndGetInfo :: CWString -> Ptr Int32 -> IO Word32
-- wszServerName : LPCWSTR -> CWString
-- netIsoError : NETISO_ERROR_TYPE* out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let networkisolationdiagnoseconnectfailureandgetinfo =
foreign "NetworkIsolationDiagnoseConnectFailureAndGetInfo"
((ptr uint16_t) @-> (ptr int32_t) @-> returning uint32_t)
(* wszServerName : LPCWSTR -> (ptr uint16_t) *)
(* netIsoError : NETISO_ERROR_TYPE* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-net-isolation-l1-1-0 (t "api-ms-win-net-isolation-l1-1-0.dll"))
(cffi:use-foreign-library api-ms-win-net-isolation-l1-1-0)
(cffi:defcfun ("NetworkIsolationDiagnoseConnectFailureAndGetInfo" network-isolation-diagnose-connect-failure-and-get-info :convention :stdcall) :uint32
(wsz-server-name (:string :encoding :utf-16le)) ; LPCWSTR
(net-iso-error :pointer)) ; NETISO_ERROR_TYPE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NetworkIsolationDiagnoseConnectFailureAndGetInfo = Win32::API::More->new('api-ms-win-net-isolation-l1-1-0',
'DWORD NetworkIsolationDiagnoseConnectFailureAndGetInfo(LPCWSTR wszServerName, LPVOID netIsoError)');
# my $ret = $NetworkIsolationDiagnoseConnectFailureAndGetInfo->Call($wszServerName, $netIsoError);
# wszServerName : LPCWSTR -> LPCWSTR
# netIsoError : NETISO_ERROR_TYPE* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型