ホーム › Storage.DistributedFileSystem › NetDfsSetClientInfo
NetDfsSetClientInfo
関数クライアント側のDFSエントリ情報を設定する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetDfsSetClientInfo(
LPWSTR DfsEntryPath,
LPWSTR ServerName, // optional
LPWSTR ShareName, // optional
DWORD Level,
BYTE* Buffer
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| DfsEntryPath | LPWSTR | in |
| ServerName | LPWSTR | inoptional |
| ShareName | LPWSTR | inoptional |
| Level | DWORD | in |
| Buffer | BYTE* | in |
戻り値の型: DWORD
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
DWORD NetDfsSetClientInfo(
LPWSTR DfsEntryPath,
LPWSTR ServerName, // optional
LPWSTR ShareName, // optional
DWORD Level,
BYTE* Buffer
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetDfsSetClientInfo(
[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*
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetDfsSetClientInfo(
<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*
) As UInteger
End Function' DfsEntryPath : LPWSTR
' ServerName : LPWSTR optional
' ShareName : LPWSTR optional
' Level : DWORD
' Buffer : BYTE*
Declare PtrSafe Function NetDfsSetClientInfo 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
NetDfsSetClientInfo = ctypes.windll.netapi32.NetDfsSetClientInfo
NetDfsSetClientInfo.restype = wintypes.DWORD
NetDfsSetClientInfo.argtypes = [
wintypes.LPCWSTR, # DfsEntryPath : LPWSTR
wintypes.LPCWSTR, # ServerName : LPWSTR optional
wintypes.LPCWSTR, # ShareName : LPWSTR optional
wintypes.DWORD, # Level : DWORD
ctypes.POINTER(ctypes.c_ubyte), # Buffer : BYTE*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
NetDfsSetClientInfo = Fiddle::Function.new(
lib['NetDfsSetClientInfo'],
[
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*
],
-Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn NetDfsSetClientInfo(
DfsEntryPath: *mut u16, // LPWSTR
ServerName: *mut u16, // LPWSTR optional
ShareName: *mut u16, // LPWSTR optional
Level: u32, // DWORD
Buffer: *mut u8 // BYTE*
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetDfsSetClientInfo([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_NetDfsSetClientInfo' -Namespace Win32 -PassThru
# $api::NetDfsSetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)#uselib "NETAPI32.dll"
#func global NetDfsSetClientInfo "NetDfsSetClientInfo" sptr, sptr, sptr, sptr, sptr
; NetDfsSetClientInfo DfsEntryPath, ServerName, ShareName, Level, varptr(Buffer) ; 戻り値は stat
; DfsEntryPath : LPWSTR -> "sptr"
; ServerName : LPWSTR optional -> "sptr"
; ShareName : LPWSTR optional -> "sptr"
; Level : DWORD -> "sptr"
; Buffer : BYTE* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "NETAPI32.dll" #cfunc global NetDfsSetClientInfo "NetDfsSetClientInfo" wstr, wstr, wstr, int, var ; res = NetDfsSetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer) ; DfsEntryPath : LPWSTR -> "wstr" ; ServerName : LPWSTR optional -> "wstr" ; ShareName : LPWSTR optional -> "wstr" ; Level : DWORD -> "int" ; Buffer : BYTE* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "NETAPI32.dll" #cfunc global NetDfsSetClientInfo "NetDfsSetClientInfo" wstr, wstr, wstr, int, sptr ; res = NetDfsSetClientInfo(DfsEntryPath, ServerName, ShareName, Level, varptr(Buffer)) ; DfsEntryPath : LPWSTR -> "wstr" ; ServerName : LPWSTR optional -> "wstr" ; ShareName : LPWSTR optional -> "wstr" ; Level : DWORD -> "int" ; Buffer : BYTE* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD NetDfsSetClientInfo(LPWSTR DfsEntryPath, LPWSTR ServerName, LPWSTR ShareName, DWORD Level, BYTE* Buffer) #uselib "NETAPI32.dll" #cfunc global NetDfsSetClientInfo "NetDfsSetClientInfo" wstr, wstr, wstr, int, var ; res = NetDfsSetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer) ; DfsEntryPath : LPWSTR -> "wstr" ; ServerName : LPWSTR optional -> "wstr" ; ShareName : LPWSTR optional -> "wstr" ; Level : DWORD -> "int" ; Buffer : BYTE* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD NetDfsSetClientInfo(LPWSTR DfsEntryPath, LPWSTR ServerName, LPWSTR ShareName, DWORD Level, BYTE* Buffer) #uselib "NETAPI32.dll" #cfunc global NetDfsSetClientInfo "NetDfsSetClientInfo" wstr, wstr, wstr, int, intptr ; res = NetDfsSetClientInfo(DfsEntryPath, ServerName, ShareName, Level, varptr(Buffer)) ; DfsEntryPath : LPWSTR -> "wstr" ; ServerName : LPWSTR optional -> "wstr" ; ShareName : LPWSTR optional -> "wstr" ; Level : DWORD -> "int" ; Buffer : BYTE* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procNetDfsSetClientInfo = netapi32.NewProc("NetDfsSetClientInfo")
)
// DfsEntryPath (LPWSTR), ServerName (LPWSTR optional), ShareName (LPWSTR optional), Level (DWORD), Buffer (BYTE*)
r1, _, err := procNetDfsSetClientInfo.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 // DWORDfunction NetDfsSetClientInfo(
DfsEntryPath: PWideChar; // LPWSTR
ServerName: PWideChar; // LPWSTR optional
ShareName: PWideChar; // LPWSTR optional
Level: DWORD; // DWORD
Buffer: Pointer // BYTE*
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetDfsSetClientInfo';result := DllCall("NETAPI32\NetDfsSetClientInfo"
, "WStr", DfsEntryPath ; LPWSTR
, "WStr", ServerName ; LPWSTR optional
, "WStr", ShareName ; LPWSTR optional
, "UInt", Level ; DWORD
, "Ptr", Buffer ; BYTE*
, "UInt") ; return: DWORD●NetDfsSetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer) = DLL("NETAPI32.dll", "dword NetDfsSetClientInfo(char*, char*, char*, dword, void*)")
# 呼び出し: NetDfsSetClientInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)
# DfsEntryPath : LPWSTR -> "char*"
# ServerName : LPWSTR optional -> "char*"
# ShareName : LPWSTR optional -> "char*"
# Level : DWORD -> "dword"
# Buffer : BYTE* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。