Win32 API 日本語リファレンス
ホームStorage.DistributedFileSystem › NetDfsGetClientInfo

NetDfsGetClientInfo

関数
クライアント側のDFSエントリ情報を取得する。
DLLNETAPI32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD NetDfsGetClientInfo(
    LPWSTR DfsEntryPath,
    LPWSTR ServerName,   // optional
    LPWSTR ShareName,   // optional
    DWORD Level,
    BYTE** Buffer
);

パラメーター

名前方向
DfsEntryPathLPWSTRin
ServerNameLPWSTRinoptional
ShareNameLPWSTRinoptional
LevelDWORDin
BufferBYTE**out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD NetDfsGetClientInfo(
    LPWSTR DfsEntryPath,
    LPWSTR ServerName,   // optional
    LPWSTR ShareName,   // optional
    DWORD Level,
    BYTE** Buffer
);
[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetDfsGetClientInfo(
    [MarshalAs(UnmanagedType.LPWStr)] string DfsEntryPath,   // LPWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string ServerName,   // LPWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string ShareName,   // LPWSTR optional
    uint Level,   // DWORD
    IntPtr Buffer   // BYTE** out
);
<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetDfsGetClientInfo(
    <MarshalAs(UnmanagedType.LPWStr)> DfsEntryPath As String,   ' LPWSTR
    <MarshalAs(UnmanagedType.LPWStr)> ServerName As String,   ' LPWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> ShareName As String,   ' LPWSTR optional
    Level As UInteger,   ' DWORD
    Buffer As IntPtr   ' BYTE** out
) As UInteger
End Function
' DfsEntryPath : LPWSTR
' ServerName : LPWSTR optional
' ShareName : LPWSTR optional
' Level : DWORD
' Buffer : BYTE** out
Declare PtrSafe Function NetDfsGetClientInfo Lib "netapi32" ( _
    ByVal DfsEntryPath As LongPtr, _
    ByVal ServerName As LongPtr, _
    ByVal ShareName As LongPtr, _
    ByVal Level As Long, _
    ByVal Buffer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NetDfsGetClientInfo = ctypes.windll.netapi32.NetDfsGetClientInfo
NetDfsGetClientInfo.restype = wintypes.DWORD
NetDfsGetClientInfo.argtypes = [
    wintypes.LPCWSTR,  # DfsEntryPath : LPWSTR
    wintypes.LPCWSTR,  # ServerName : LPWSTR optional
    wintypes.LPCWSTR,  # ShareName : LPWSTR optional
    wintypes.DWORD,  # Level : DWORD
    ctypes.c_void_p,  # Buffer : BYTE** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NETAPI32.dll')
NetDfsGetClientInfo = Fiddle::Function.new(
  lib['NetDfsGetClientInfo'],
  [
    Fiddle::TYPE_VOIDP,  # DfsEntryPath : LPWSTR
    Fiddle::TYPE_VOIDP,  # ServerName : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # ShareName : LPWSTR optional
    -Fiddle::TYPE_INT,  # Level : DWORD
    Fiddle::TYPE_VOIDP,  # Buffer : BYTE** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "netapi32")]
extern "system" {
    fn NetDfsGetClientInfo(
        DfsEntryPath: *mut u16,  // LPWSTR
        ServerName: *mut u16,  // LPWSTR optional
        ShareName: *mut u16,  // LPWSTR optional
        Level: u32,  // DWORD
        Buffer: *mut *mut u8  // BYTE** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetDfsGetClientInfo([MarshalAs(UnmanagedType.LPWStr)] string DfsEntryPath, [MarshalAs(UnmanagedType.LPWStr)] string ServerName, [MarshalAs(UnmanagedType.LPWStr)] string ShareName, uint Level, IntPtr Buffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetDfsGetClientInfo' -Namespace Win32 -PassThru
# $api::NetDfsGetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)
#uselib "NETAPI32.dll"
#func global NetDfsGetClientInfo "NetDfsGetClientInfo" sptr, sptr, sptr, sptr, sptr
; NetDfsGetClientInfo DfsEntryPath, ServerName, ShareName, Level, varptr(Buffer)   ; 戻り値は stat
; DfsEntryPath : LPWSTR -> "sptr"
; ServerName : LPWSTR optional -> "sptr"
; ShareName : LPWSTR optional -> "sptr"
; Level : DWORD -> "sptr"
; Buffer : BYTE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "NETAPI32.dll"
#cfunc global NetDfsGetClientInfo "NetDfsGetClientInfo" wstr, wstr, wstr, int, var
; res = NetDfsGetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)
; DfsEntryPath : LPWSTR -> "wstr"
; ServerName : LPWSTR optional -> "wstr"
; ShareName : LPWSTR optional -> "wstr"
; Level : DWORD -> "int"
; Buffer : BYTE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD NetDfsGetClientInfo(LPWSTR DfsEntryPath, LPWSTR ServerName, LPWSTR ShareName, DWORD Level, BYTE** Buffer)
#uselib "NETAPI32.dll"
#cfunc global NetDfsGetClientInfo "NetDfsGetClientInfo" wstr, wstr, wstr, int, var
; res = NetDfsGetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)
; DfsEntryPath : LPWSTR -> "wstr"
; ServerName : LPWSTR optional -> "wstr"
; ShareName : LPWSTR optional -> "wstr"
; Level : DWORD -> "int"
; Buffer : BYTE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetDfsGetClientInfo = netapi32.NewProc("NetDfsGetClientInfo")
)

// DfsEntryPath (LPWSTR), ServerName (LPWSTR optional), ShareName (LPWSTR optional), Level (DWORD), Buffer (BYTE** out)
r1, _, err := procNetDfsGetClientInfo.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DfsEntryPath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ShareName))),
	uintptr(Level),
	uintptr(Buffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function NetDfsGetClientInfo(
  DfsEntryPath: PWideChar;   // LPWSTR
  ServerName: PWideChar;   // LPWSTR optional
  ShareName: PWideChar;   // LPWSTR optional
  Level: DWORD;   // DWORD
  Buffer: Pointer   // BYTE** out
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'NetDfsGetClientInfo';
result := DllCall("NETAPI32\NetDfsGetClientInfo"
    , "WStr", DfsEntryPath   ; LPWSTR
    , "WStr", ServerName   ; LPWSTR optional
    , "WStr", ShareName   ; LPWSTR optional
    , "UInt", Level   ; DWORD
    , "Ptr", Buffer   ; BYTE** out
    , "UInt")   ; return: DWORD
●NetDfsGetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer) = DLL("NETAPI32.dll", "dword NetDfsGetClientInfo(char*, char*, char*, dword, void*)")
# 呼び出し: NetDfsGetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)
# DfsEntryPath : LPWSTR -> "char*"
# ServerName : LPWSTR optional -> "char*"
# ShareName : LPWSTR optional -> "char*"
# Level : DWORD -> "dword"
# Buffer : BYTE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。