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

NdfCreateSharingIncident

関数
ファイル共有UNCパスに関する診断インシデントを作成する。
DLLNDFAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT NdfCreateSharingIncident(
    LPCWSTR UNCPath,
    void** handle
);

パラメーター

名前方向
UNCPathLPCWSTRin
handlevoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT NdfCreateSharingIncident(
    LPCWSTR UNCPath,
    void** handle
);
[DllImport("NDFAPI.dll", ExactSpelling = true)]
static extern int NdfCreateSharingIncident(
    [MarshalAs(UnmanagedType.LPWStr)] string UNCPath,   // LPCWSTR
    IntPtr handle   // void** out
);
<DllImport("NDFAPI.dll", ExactSpelling:=True)>
Public Shared Function NdfCreateSharingIncident(
    <MarshalAs(UnmanagedType.LPWStr)> UNCPath As String,   ' LPCWSTR
    handle As IntPtr   ' void** out
) As Integer
End Function
' UNCPath : LPCWSTR
' handle : void** out
Declare PtrSafe Function NdfCreateSharingIncident Lib "ndfapi" ( _
    ByVal UNCPath 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

NdfCreateSharingIncident = ctypes.windll.ndfapi.NdfCreateSharingIncident
NdfCreateSharingIncident.restype = ctypes.c_int
NdfCreateSharingIncident.argtypes = [
    wintypes.LPCWSTR,  # UNCPath : LPCWSTR
    ctypes.c_void_p,  # handle : void** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ndfapi = windows.NewLazySystemDLL("NDFAPI.dll")
	procNdfCreateSharingIncident = ndfapi.NewProc("NdfCreateSharingIncident")
)

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