ホーム › NetworkManagement.NetworkDiagnosticsFramework › NdfCreateDNSIncident
NdfCreateDNSIncident
関数DNS名前解決に関する診断インシデントを作成する。
シグネチャ
// NDFAPI.dll
#include <windows.h>
HRESULT NdfCreateDNSIncident(
LPCWSTR hostname,
WORD queryType,
void** handle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hostname | LPCWSTR | in | 診断対象のDNS名前解決のホスト名を指定する。 |
| queryType | WORD | in | 診断するDNSクエリの種類(レコードタイプ)を指定する。 |
| handle | void** | out | 作成された診断インシデントのハンドルを受け取るポインター。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// NDFAPI.dll
#include <windows.h>
HRESULT NdfCreateDNSIncident(
LPCWSTR hostname,
WORD queryType,
void** handle
);[DllImport("NDFAPI.dll", ExactSpelling = true)]
static extern int NdfCreateDNSIncident(
[MarshalAs(UnmanagedType.LPWStr)] string hostname, // LPCWSTR
ushort queryType, // WORD
IntPtr handle // void** out
);<DllImport("NDFAPI.dll", ExactSpelling:=True)>
Public Shared Function NdfCreateDNSIncident(
<MarshalAs(UnmanagedType.LPWStr)> hostname As String, ' LPCWSTR
queryType As UShort, ' WORD
handle As IntPtr ' void** out
) As Integer
End Function' hostname : LPCWSTR
' queryType : WORD
' handle : void** out
Declare PtrSafe Function NdfCreateDNSIncident Lib "ndfapi" ( _
ByVal hostname As LongPtr, _
ByVal queryType As Integer, _
ByVal handle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NdfCreateDNSIncident = ctypes.windll.ndfapi.NdfCreateDNSIncident
NdfCreateDNSIncident.restype = ctypes.c_int
NdfCreateDNSIncident.argtypes = [
wintypes.LPCWSTR, # hostname : LPCWSTR
ctypes.c_ushort, # queryType : WORD
ctypes.c_void_p, # handle : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NDFAPI.dll')
NdfCreateDNSIncident = Fiddle::Function.new(
lib['NdfCreateDNSIncident'],
[
Fiddle::TYPE_VOIDP, # hostname : LPCWSTR
-Fiddle::TYPE_SHORT, # queryType : WORD
Fiddle::TYPE_VOIDP, # handle : void** out
],
Fiddle::TYPE_INT)#[link(name = "ndfapi")]
extern "system" {
fn NdfCreateDNSIncident(
hostname: *const u16, // LPCWSTR
queryType: u16, // WORD
handle: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NDFAPI.dll")]
public static extern int NdfCreateDNSIncident([MarshalAs(UnmanagedType.LPWStr)] string hostname, ushort queryType, IntPtr handle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NDFAPI_NdfCreateDNSIncident' -Namespace Win32 -PassThru
# $api::NdfCreateDNSIncident(hostname, queryType, handle)#uselib "NDFAPI.dll"
#func global NdfCreateDNSIncident "NdfCreateDNSIncident" sptr, sptr, sptr
; NdfCreateDNSIncident hostname, queryType, handle ; 戻り値は stat
; hostname : LPCWSTR -> "sptr"
; queryType : WORD -> "sptr"
; handle : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "NDFAPI.dll"
#cfunc global NdfCreateDNSIncident "NdfCreateDNSIncident" wstr, int, sptr
; res = NdfCreateDNSIncident(hostname, queryType, handle)
; hostname : LPCWSTR -> "wstr"
; queryType : WORD -> "int"
; handle : void** out -> "sptr"; HRESULT NdfCreateDNSIncident(LPCWSTR hostname, WORD queryType, void** handle)
#uselib "NDFAPI.dll"
#cfunc global NdfCreateDNSIncident "NdfCreateDNSIncident" wstr, int, intptr
; res = NdfCreateDNSIncident(hostname, queryType, handle)
; hostname : LPCWSTR -> "wstr"
; queryType : WORD -> "int"
; handle : void** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ndfapi = windows.NewLazySystemDLL("NDFAPI.dll")
procNdfCreateDNSIncident = ndfapi.NewProc("NdfCreateDNSIncident")
)
// hostname (LPCWSTR), queryType (WORD), handle (void** out)
r1, _, err := procNdfCreateDNSIncident.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(hostname))),
uintptr(queryType),
uintptr(handle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction NdfCreateDNSIncident(
hostname: PWideChar; // LPCWSTR
queryType: Word; // WORD
handle: Pointer // void** out
): Integer; stdcall;
external 'NDFAPI.dll' name 'NdfCreateDNSIncident';result := DllCall("NDFAPI\NdfCreateDNSIncident"
, "WStr", hostname ; LPCWSTR
, "UShort", queryType ; WORD
, "Ptr", handle ; void** out
, "Int") ; return: HRESULT●NdfCreateDNSIncident(hostname, queryType, handle) = DLL("NDFAPI.dll", "int NdfCreateDNSIncident(char*, int, void*)")
# 呼び出し: NdfCreateDNSIncident(hostname, queryType, handle)
# hostname : LPCWSTR -> "char*"
# queryType : WORD -> "int"
# handle : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ndfapi" fn NdfCreateDNSIncident(
hostname: [*c]const u16, // LPCWSTR
queryType: u16, // WORD
handle: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc NdfCreateDNSIncident(
hostname: WideCString, # LPCWSTR
queryType: uint16, # WORD
handle: pointer # void** out
): int32 {.importc: "NdfCreateDNSIncident", stdcall, dynlib: "NDFAPI.dll".}pragma(lib, "ndfapi");
extern(Windows)
int NdfCreateDNSIncident(
const(wchar)* hostname, // LPCWSTR
ushort queryType, // WORD
void** handle // void** out
);ccall((:NdfCreateDNSIncident, "NDFAPI.dll"), stdcall, Int32,
(Cwstring, UInt16, Ptr{Cvoid}),
hostname, queryType, handle)
# hostname : LPCWSTR -> Cwstring
# queryType : WORD -> UInt16
# handle : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t NdfCreateDNSIncident(
const uint16_t* hostname,
uint16_t queryType,
void** handle);
]]
local ndfapi = ffi.load("ndfapi")
-- ndfapi.NdfCreateDNSIncident(hostname, queryType, handle)
-- hostname : LPCWSTR
-- queryType : WORD
-- handle : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('NDFAPI.dll');
const NdfCreateDNSIncident = lib.func('__stdcall', 'NdfCreateDNSIncident', 'int32_t', ['str16', 'uint16_t', 'void *']);
// NdfCreateDNSIncident(hostname, queryType, handle)
// hostname : LPCWSTR -> 'str16'
// queryType : WORD -> 'uint16_t'
// handle : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NDFAPI.dll", {
NdfCreateDNSIncident: { parameters: ["buffer", "u16", "pointer"], result: "i32" },
});
// lib.symbols.NdfCreateDNSIncident(hostname, queryType, handle)
// hostname : LPCWSTR -> "buffer"
// queryType : WORD -> "u16"
// handle : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t NdfCreateDNSIncident(
const uint16_t* hostname,
uint16_t queryType,
void** handle);
C, "NDFAPI.dll");
// $ffi->NdfCreateDNSIncident(hostname, queryType, handle);
// hostname : LPCWSTR
// queryType : WORD
// handle : void** 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 Ndfapi extends StdCallLibrary {
Ndfapi INSTANCE = Native.load("ndfapi", Ndfapi.class);
int NdfCreateDNSIncident(
WString hostname, // LPCWSTR
short queryType, // WORD
Pointer handle // void** out
);
}@[Link("ndfapi")]
lib LibNDFAPI
fun NdfCreateDNSIncident = NdfCreateDNSIncident(
hostname : UInt16*, # LPCWSTR
queryType : UInt16, # WORD
handle : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NdfCreateDNSIncidentNative = Int32 Function(Pointer<Utf16>, Uint16, Pointer<Void>);
typedef NdfCreateDNSIncidentDart = int Function(Pointer<Utf16>, int, Pointer<Void>);
final NdfCreateDNSIncident = DynamicLibrary.open('NDFAPI.dll')
.lookupFunction<NdfCreateDNSIncidentNative, NdfCreateDNSIncidentDart>('NdfCreateDNSIncident');
// hostname : LPCWSTR -> Pointer<Utf16>
// queryType : WORD -> Uint16
// handle : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NdfCreateDNSIncident(
hostname: PWideChar; // LPCWSTR
queryType: Word; // WORD
handle: Pointer // void** out
): Integer; stdcall;
external 'NDFAPI.dll' name 'NdfCreateDNSIncident';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NdfCreateDNSIncident"
c_NdfCreateDNSIncident :: CWString -> Word16 -> Ptr () -> IO Int32
-- hostname : LPCWSTR -> CWString
-- queryType : WORD -> Word16
-- handle : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ndfcreatednsincident =
foreign "NdfCreateDNSIncident"
((ptr uint16_t) @-> uint16_t @-> (ptr void) @-> returning int32_t)
(* hostname : LPCWSTR -> (ptr uint16_t) *)
(* queryType : WORD -> uint16_t *)
(* handle : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ndfapi (t "NDFAPI.dll"))
(cffi:use-foreign-library ndfapi)
(cffi:defcfun ("NdfCreateDNSIncident" ndf-create-dnsincident :convention :stdcall) :int32
(hostname (:string :encoding :utf-16le)) ; LPCWSTR
(query-type :uint16) ; WORD
(handle :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NdfCreateDNSIncident = Win32::API::More->new('NDFAPI',
'int NdfCreateDNSIncident(LPCWSTR hostname, WORD queryType, LPVOID handle)');
# my $ret = $NdfCreateDNSIncident->Call($hostname, $queryType, $handle);
# hostname : LPCWSTR -> LPCWSTR
# queryType : WORD -> WORD
# handle : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。