Win32 API 日本語リファレンス
ホームNetworkManagement.NetworkDiagnosticsFramework › NdfCreateWebIncidentEx

NdfCreateWebIncidentEx

関数
オプション指定でWeb接続の診断インシデントを作成する。
DLLNDFAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// NDFAPI.dll
#include <windows.h>

HRESULT NdfCreateWebIncidentEx(
    LPCWSTR url,
    BOOL useWinHTTP,
    LPWSTR moduleName,   // optional
    void** handle
);

パラメーター

名前方向説明
urlLPCWSTRin診断対象のWeb URLを指定する。
useWinHTTPBOOLinWinHTTP経由で診断するかを指定する真偽値。
moduleNameLPWSTRinoptional診断に使うモジュール名を指定する。NULL可。
handlevoid**out作成された診断インシデントのハンドルを受け取るポインター。

戻り値の型: HRESULT

各言語での呼び出し定義

// NDFAPI.dll
#include <windows.h>

HRESULT NdfCreateWebIncidentEx(
    LPCWSTR url,
    BOOL useWinHTTP,
    LPWSTR moduleName,   // optional
    void** handle
);
[DllImport("NDFAPI.dll", ExactSpelling = true)]
static extern int NdfCreateWebIncidentEx(
    [MarshalAs(UnmanagedType.LPWStr)] string url,   // LPCWSTR
    bool useWinHTTP,   // BOOL
    [MarshalAs(UnmanagedType.LPWStr)] string moduleName,   // LPWSTR optional
    IntPtr handle   // void** out
);
<DllImport("NDFAPI.dll", ExactSpelling:=True)>
Public Shared Function NdfCreateWebIncidentEx(
    <MarshalAs(UnmanagedType.LPWStr)> url As String,   ' LPCWSTR
    useWinHTTP As Boolean,   ' BOOL
    <MarshalAs(UnmanagedType.LPWStr)> moduleName As String,   ' LPWSTR optional
    handle As IntPtr   ' void** out
) As Integer
End Function
' url : LPCWSTR
' useWinHTTP : BOOL
' moduleName : LPWSTR optional
' handle : void** out
Declare PtrSafe Function NdfCreateWebIncidentEx Lib "ndfapi" ( _
    ByVal url As LongPtr, _
    ByVal useWinHTTP As Long, _
    ByVal moduleName As LongPtr, _
    ByVal handle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NdfCreateWebIncidentEx = ctypes.windll.ndfapi.NdfCreateWebIncidentEx
NdfCreateWebIncidentEx.restype = ctypes.c_int
NdfCreateWebIncidentEx.argtypes = [
    wintypes.LPCWSTR,  # url : LPCWSTR
    wintypes.BOOL,  # useWinHTTP : BOOL
    wintypes.LPCWSTR,  # moduleName : LPWSTR optional
    ctypes.c_void_p,  # handle : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NDFAPI.dll')
NdfCreateWebIncidentEx = Fiddle::Function.new(
  lib['NdfCreateWebIncidentEx'],
  [
    Fiddle::TYPE_VOIDP,  # url : LPCWSTR
    Fiddle::TYPE_INT,  # useWinHTTP : BOOL
    Fiddle::TYPE_VOIDP,  # moduleName : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # handle : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "ndfapi")]
extern "system" {
    fn NdfCreateWebIncidentEx(
        url: *const u16,  // LPCWSTR
        useWinHTTP: i32,  // BOOL
        moduleName: *mut u16,  // LPWSTR optional
        handle: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NDFAPI.dll")]
public static extern int NdfCreateWebIncidentEx([MarshalAs(UnmanagedType.LPWStr)] string url, bool useWinHTTP, [MarshalAs(UnmanagedType.LPWStr)] string moduleName, IntPtr handle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NDFAPI_NdfCreateWebIncidentEx' -Namespace Win32 -PassThru
# $api::NdfCreateWebIncidentEx(url, useWinHTTP, moduleName, handle)
#uselib "NDFAPI.dll"
#func global NdfCreateWebIncidentEx "NdfCreateWebIncidentEx" sptr, sptr, sptr, sptr
; NdfCreateWebIncidentEx url, useWinHTTP, moduleName, handle   ; 戻り値は stat
; url : LPCWSTR -> "sptr"
; useWinHTTP : BOOL -> "sptr"
; moduleName : LPWSTR optional -> "sptr"
; handle : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "NDFAPI.dll"
#cfunc global NdfCreateWebIncidentEx "NdfCreateWebIncidentEx" wstr, int, wstr, sptr
; res = NdfCreateWebIncidentEx(url, useWinHTTP, moduleName, handle)
; url : LPCWSTR -> "wstr"
; useWinHTTP : BOOL -> "int"
; moduleName : LPWSTR optional -> "wstr"
; handle : void** out -> "sptr"
; HRESULT NdfCreateWebIncidentEx(LPCWSTR url, BOOL useWinHTTP, LPWSTR moduleName, void** handle)
#uselib "NDFAPI.dll"
#cfunc global NdfCreateWebIncidentEx "NdfCreateWebIncidentEx" wstr, int, wstr, intptr
; res = NdfCreateWebIncidentEx(url, useWinHTTP, moduleName, handle)
; url : LPCWSTR -> "wstr"
; useWinHTTP : BOOL -> "int"
; moduleName : LPWSTR optional -> "wstr"
; handle : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ndfapi = windows.NewLazySystemDLL("NDFAPI.dll")
	procNdfCreateWebIncidentEx = ndfapi.NewProc("NdfCreateWebIncidentEx")
)

// url (LPCWSTR), useWinHTTP (BOOL), moduleName (LPWSTR optional), handle (void** out)
r1, _, err := procNdfCreateWebIncidentEx.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(url))),
	uintptr(useWinHTTP),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(moduleName))),
	uintptr(handle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function NdfCreateWebIncidentEx(
  url: PWideChar;   // LPCWSTR
  useWinHTTP: BOOL;   // BOOL
  moduleName: PWideChar;   // LPWSTR optional
  handle: Pointer   // void** out
): Integer; stdcall;
  external 'NDFAPI.dll' name 'NdfCreateWebIncidentEx';
result := DllCall("NDFAPI\NdfCreateWebIncidentEx"
    , "WStr", url   ; LPCWSTR
    , "Int", useWinHTTP   ; BOOL
    , "WStr", moduleName   ; LPWSTR optional
    , "Ptr", handle   ; void** out
    , "Int")   ; return: HRESULT
●NdfCreateWebIncidentEx(url, useWinHTTP, moduleName, handle) = DLL("NDFAPI.dll", "int NdfCreateWebIncidentEx(char*, bool, char*, void*)")
# 呼び出し: NdfCreateWebIncidentEx(url, useWinHTTP, moduleName, handle)
# url : LPCWSTR -> "char*"
# useWinHTTP : BOOL -> "bool"
# moduleName : LPWSTR optional -> "char*"
# handle : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "ndfapi" fn NdfCreateWebIncidentEx(
    url: [*c]const u16, // LPCWSTR
    useWinHTTP: i32, // BOOL
    moduleName: [*c]const u16, // LPWSTR optional
    handle: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;
proc NdfCreateWebIncidentEx(
    url: WideCString,  # LPCWSTR
    useWinHTTP: int32,  # BOOL
    moduleName: WideCString,  # LPWSTR optional
    handle: pointer  # void** out
): int32 {.importc: "NdfCreateWebIncidentEx", stdcall, dynlib: "NDFAPI.dll".}
pragma(lib, "ndfapi");
extern(Windows)
int NdfCreateWebIncidentEx(
    const(wchar)* url,   // LPCWSTR
    int useWinHTTP,   // BOOL
    const(wchar)* moduleName,   // LPWSTR optional
    void** handle   // void** out
);
ccall((:NdfCreateWebIncidentEx, "NDFAPI.dll"), stdcall, Int32,
      (Cwstring, Int32, Cwstring, Ptr{Cvoid}),
      url, useWinHTTP, moduleName, handle)
# url : LPCWSTR -> Cwstring
# useWinHTTP : BOOL -> Int32
# moduleName : LPWSTR optional -> Cwstring
# handle : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t NdfCreateWebIncidentEx(
    const uint16_t* url,
    int32_t useWinHTTP,
    const uint16_t* moduleName,
    void** handle);
]]
local ndfapi = ffi.load("ndfapi")
-- ndfapi.NdfCreateWebIncidentEx(url, useWinHTTP, moduleName, handle)
-- url : LPCWSTR
-- useWinHTTP : BOOL
-- moduleName : LPWSTR optional
-- handle : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('NDFAPI.dll');
const NdfCreateWebIncidentEx = lib.func('__stdcall', 'NdfCreateWebIncidentEx', 'int32_t', ['str16', 'int32_t', 'str16', 'void *']);
// NdfCreateWebIncidentEx(url, useWinHTTP, moduleName, handle)
// url : LPCWSTR -> 'str16'
// useWinHTTP : BOOL -> 'int32_t'
// moduleName : LPWSTR optional -> 'str16'
// handle : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("NDFAPI.dll", {
  NdfCreateWebIncidentEx: { parameters: ["buffer", "i32", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.NdfCreateWebIncidentEx(url, useWinHTTP, moduleName, handle)
// url : LPCWSTR -> "buffer"
// useWinHTTP : BOOL -> "i32"
// moduleName : LPWSTR optional -> "buffer"
// handle : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t NdfCreateWebIncidentEx(
    const uint16_t* url,
    int32_t useWinHTTP,
    const uint16_t* moduleName,
    void** handle);
C, "NDFAPI.dll");
// $ffi->NdfCreateWebIncidentEx(url, useWinHTTP, moduleName, handle);
// url : LPCWSTR
// useWinHTTP : BOOL
// moduleName : LPWSTR optional
// 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 NdfCreateWebIncidentEx(
        WString url,   // LPCWSTR
        boolean useWinHTTP,   // BOOL
        WString moduleName,   // LPWSTR optional
        Pointer handle   // void** out
    );
}
@[Link("ndfapi")]
lib LibNDFAPI
  fun NdfCreateWebIncidentEx = NdfCreateWebIncidentEx(
    url : UInt16*,   # LPCWSTR
    useWinHTTP : Int32,   # BOOL
    moduleName : UInt16*,   # LPWSTR optional
    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 NdfCreateWebIncidentExNative = Int32 Function(Pointer<Utf16>, Int32, Pointer<Utf16>, Pointer<Void>);
typedef NdfCreateWebIncidentExDart = int Function(Pointer<Utf16>, int, Pointer<Utf16>, Pointer<Void>);
final NdfCreateWebIncidentEx = DynamicLibrary.open('NDFAPI.dll')
    .lookupFunction<NdfCreateWebIncidentExNative, NdfCreateWebIncidentExDart>('NdfCreateWebIncidentEx');
// url : LPCWSTR -> Pointer<Utf16>
// useWinHTTP : BOOL -> Int32
// moduleName : LPWSTR optional -> Pointer<Utf16>
// handle : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function NdfCreateWebIncidentEx(
  url: PWideChar;   // LPCWSTR
  useWinHTTP: BOOL;   // BOOL
  moduleName: PWideChar;   // LPWSTR optional
  handle: Pointer   // void** out
): Integer; stdcall;
  external 'NDFAPI.dll' name 'NdfCreateWebIncidentEx';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "NdfCreateWebIncidentEx"
  c_NdfCreateWebIncidentEx :: CWString -> CInt -> CWString -> Ptr () -> IO Int32
-- url : LPCWSTR -> CWString
-- useWinHTTP : BOOL -> CInt
-- moduleName : LPWSTR optional -> CWString
-- handle : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ndfcreatewebincidentex =
  foreign "NdfCreateWebIncidentEx"
    ((ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* url : LPCWSTR -> (ptr uint16_t) *)
(* useWinHTTP : BOOL -> int32_t *)
(* moduleName : LPWSTR optional -> (ptr 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 ("NdfCreateWebIncidentEx" ndf-create-web-incident-ex :convention :stdcall) :int32
  (url (:string :encoding :utf-16le))   ; LPCWSTR
  (use-win-http :int32)   ; BOOL
  (module-name (:string :encoding :utf-16le))   ; LPWSTR optional
  (handle :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $NdfCreateWebIncidentEx = Win32::API::More->new('NDFAPI',
    'int NdfCreateWebIncidentEx(LPCWSTR url, BOOL useWinHTTP, LPCWSTR moduleName, LPVOID handle)');
# my $ret = $NdfCreateWebIncidentEx->Call($url, $useWinHTTP, $moduleName, $handle);
# url : LPCWSTR -> LPCWSTR
# useWinHTTP : BOOL -> BOOL
# moduleName : LPWSTR optional -> LPCWSTR
# handle : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API