NetDfsSetInfo
関数シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetDfsSetInfo(
LPWSTR DfsEntryPath,
LPWSTR ServerName, // optional
LPWSTR ShareName, // optional
DWORD Level,
BYTE* Buffer
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| DfsEntryPath | LPWSTR | in | DFS のルートまたはリンクの Universal Naming Convention (UNC) パスを指定する文字列へのポインター。 リンクの場合、文字列は次の 2 つの形式のいずれかを取ります。1 つ目の形式は次のとおりです。 \\ServerName\DfsName\link_path ここで ServerName はスタンドアロンの DFS 名前空間をホストするルート ターゲット サーバーの名前、DfsName は DFS 名前空間の名前、 link_path は DFS リンクです。 2 つ目の形式は次のとおりです。 \\DomainName\DomDfsname\link_path ここで DomainName はドメインベースの DFS 名前空間をホストするドメインの名前、 DomDfsname は DFS 名前空間の名前、 link_path は DFS リンクです。 ルートの場合、文字列は次の 2 つの形式のいずれかを取ります。 \\ServerName\DfsName または \\DomainName\DomDfsname 各名前の値の意味は前述のとおりです。 |
| ServerName | LPWSTR | inoptional | DFS リンク ターゲットのサーバー名を指定する文字列へのポインター。このパラメーターは省略可能です。詳細については、 「解説」セクションを参照してください。 |
| ShareName | LPWSTR | inoptional | DFS リンク ターゲットの共有名を指定する文字列へのポインター。共有に対する相対パスを含む共有名を指定することもできます。 たとえば "share1\mydir1\mydir2" のように指定します。このパラメーターは省略可能です。詳細については、 「解説」セクションを参照してください。 |
| Level | DWORD | in | データの情報レベルを指定します。このパラメーターには、次のいずれかの値を指定できます。 100DfsEntryPath パラメーターで指定した DFS のルートまたはリンクに関連付けられたコメントを 設定します。Buffer パラメーターは DFS_INFO_100 構造体を指します。 101DfsEntryPath パラメーターで指定した DFS のルートまたはリンクに関連付けられたストレージの状態を 設定します。Buffer パラメーターは DFS_INFO_101 構造体を指します。 102DfsEntryPath パラメーターで指定した DFS のルートまたはリンクに関連付けられたタイムアウト値を 設定します。Buffer パラメーターは DFS_INFO_102 構造体を指します。 103DfsEntryPath パラメーターで指定した DFS のルートまたはリンクのプロパティ フラグを設定します。 Buffer パラメーターは DFS_INFO_103 構造体を指します。 104DfsEntryPath パラメーターで指定したルート ターゲットまたはリンク ターゲットの ターゲット優先順位のランクとクラスを設定します。Buffer パラメーターは DFS_INFO_104 構造体を指します。 105DfsEntryPath パラメーターで指定した DFS のルートまたはリンクについて、コメント、状態、 タイムアウト情報、およびプロパティ フラグを設定します。Buffer パラメーターは DFS_INFO_105 構造体を指します。 106DfsEntryPath パラメーターで指定したルート ターゲットまたはリンク ターゲットの ターゲットの状態と優先順位を設定します。この情報は DFS 名前空間のルートやリンクには設定できず、 ルート ターゲットまたはリンク ターゲットに対してのみ設定できます。Buffer パラメーターは DFS_INFO_106 構造体を指します。 107DfsEntryPath パラメーターで指定した DFS のルートまたはリンクについて、コメント、状態、 タイムアウト情報、およびプロパティ フラグを設定します。DFS リンクの場合は、 リンクの再解析ポイントのセキュリティ記述子も設定できます。Buffer パラメーターは DFS_INFO_107 構造体を指します。 150DFS リンクの再解析ポイントのセキュリティ記述子を設定します。Buffer パラメーターは DFS_INFO_150 構造体を指します。 |
| Buffer | BYTE* | in | データを指定するバッファーへのポインター。このデータの形式は Level パラメーターの値によって異なります。詳細については、 Network Management Function Buffers を参照してください。 |
戻り値の型: DWORD
公式ドキュメント
特定の分散ファイル システム (DFS) のルート、ルート ターゲット、リンク、またはリンク ターゲットに関する情報を設定または変更します。
戻り値
関数が成功した場合、戻り値は NERR_Success です。
関数が失敗した場合、戻り値はシステム エラー コードです。エラー コードの一覧については、 System Error Codes を参照してください。
解説(Remarks)
呼び出し元は DFS サーバーに対する Administrator 特権を持っている必要があります。管理者特権を必要とする関数の 呼び出しの詳細については、 Running with Special Privileges を参照してください。
ServerName パラメーターと ShareName パラメーターの両方を指定した場合、 NetDfsSetInfo 関数はそのルート ターゲットまたはリンク ターゲットに固有の情報を設定または変更します。 これらのパラメーターが NULL の場合、この関数は特定の DFS ルート ターゲットやリンク ターゲットではなく、 DFS 名前空間のルートまたは DFS リンクに固有の情報を設定または変更します。
DFS のルートまたはリンクに設定できるコメントとタイムアウトはそれぞれ 1 つだけであるため、 情報レベル 100 および 102 では ServerName パラメーターと ShareName パラメーターは 無視されます。これらのパラメーターはレベル 101 では必須です。
情報レベル 101 では、DFS 名前空間に複数の DFS ルート ターゲットが存在する場合、特定のドメインベース DFS ルートに対して DFS_VOLUME_STATE_RESYNCHRONIZE および DFS_VOLUME_STATE_STANDBY の状態値を次のように 設定できます。
DfsEntryPath パラメーターでドメインベースの DFS 名前空間を指定し、 ServerName パラメーターと ShareName パラメーターの組み合わせで、 情報設定操作を実行する DFS ルート ターゲットを指定します。
Examples
次のコード サンプルは、NetDfsSetInfo 関数の呼び出しによって DFS リンクにコメントを関連付ける方法を 示しています。このサンプルでは情報レベル 100 (DFS_INFO_100) を指定しています。
#include <windows.h>
#include <lm.h>
#include <lmdfs.h>
#include <stdio.h>
#pragma comment(lib, "Netapi32.lib")
void wmain(int argc, wchar_t *argv[])
{
DFS_INFO_100 dfsData;
DWORD res;
//
// Check command line arguments.
//
if (argc<2)
wprintf(L"Syntax: %s DfsEntryPath [\"Comment\"]\n", argv[0]);
else
{
//
// Fill in DFS_INFO_100 structure member.
//
dfsData.Comment = argc < 3 ? NULL : argv[2];
//
// Call the NetDfsSetInfo function, specifying level 100.
//
res = NetDfsSetInfo(argv[1], NULL, NULL, 100, (LPBYTE) &dfsData);
//
// Display the result of the call.
//
if(res == 0)
printf("Comment set.\n");
else
printf("Error: %u", res);
}
return;
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
DWORD NetDfsSetInfo(
LPWSTR DfsEntryPath,
LPWSTR ServerName, // optional
LPWSTR ShareName, // optional
DWORD Level,
BYTE* Buffer
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetDfsSetInfo(
[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 NetDfsSetInfo(
<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 NetDfsSetInfo 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
NetDfsSetInfo = ctypes.windll.netapi32.NetDfsSetInfo
NetDfsSetInfo.restype = wintypes.DWORD
NetDfsSetInfo.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')
NetDfsSetInfo = Fiddle::Function.new(
lib['NetDfsSetInfo'],
[
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 NetDfsSetInfo(
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 NetDfsSetInfo([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_NetDfsSetInfo' -Namespace Win32 -PassThru
# $api::NetDfsSetInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)#uselib "NETAPI32.dll"
#func global NetDfsSetInfo "NetDfsSetInfo" sptr, sptr, sptr, sptr, sptr
; NetDfsSetInfo 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 NetDfsSetInfo "NetDfsSetInfo" wstr, wstr, wstr, int, var ; res = NetDfsSetInfo(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 NetDfsSetInfo "NetDfsSetInfo" wstr, wstr, wstr, int, sptr ; res = NetDfsSetInfo(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 NetDfsSetInfo(LPWSTR DfsEntryPath, LPWSTR ServerName, LPWSTR ShareName, DWORD Level, BYTE* Buffer) #uselib "NETAPI32.dll" #cfunc global NetDfsSetInfo "NetDfsSetInfo" wstr, wstr, wstr, int, var ; res = NetDfsSetInfo(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 NetDfsSetInfo(LPWSTR DfsEntryPath, LPWSTR ServerName, LPWSTR ShareName, DWORD Level, BYTE* Buffer) #uselib "NETAPI32.dll" #cfunc global NetDfsSetInfo "NetDfsSetInfo" wstr, wstr, wstr, int, intptr ; res = NetDfsSetInfo(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")
procNetDfsSetInfo = netapi32.NewProc("NetDfsSetInfo")
)
// DfsEntryPath (LPWSTR), ServerName (LPWSTR optional), ShareName (LPWSTR optional), Level (DWORD), Buffer (BYTE*)
r1, _, err := procNetDfsSetInfo.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 NetDfsSetInfo(
DfsEntryPath: PWideChar; // LPWSTR
ServerName: PWideChar; // LPWSTR optional
ShareName: PWideChar; // LPWSTR optional
Level: DWORD; // DWORD
Buffer: Pointer // BYTE*
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetDfsSetInfo';result := DllCall("NETAPI32\NetDfsSetInfo"
, "WStr", DfsEntryPath ; LPWSTR
, "WStr", ServerName ; LPWSTR optional
, "WStr", ShareName ; LPWSTR optional
, "UInt", Level ; DWORD
, "Ptr", Buffer ; BYTE*
, "UInt") ; return: DWORD●NetDfsSetInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer) = DLL("NETAPI32.dll", "dword NetDfsSetInfo(char*, char*, char*, dword, void*)")
# 呼び出し: NetDfsSetInfo(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)。const std = @import("std");
extern "netapi32" fn NetDfsSetInfo(
DfsEntryPath: [*c]const u16, // LPWSTR
ServerName: [*c]const u16, // LPWSTR optional
ShareName: [*c]const u16, // LPWSTR optional
Level: u32, // DWORD
Buffer: [*c]u8 // BYTE*
) callconv(std.os.windows.WINAPI) u32;proc NetDfsSetInfo(
DfsEntryPath: WideCString, # LPWSTR
ServerName: WideCString, # LPWSTR optional
ShareName: WideCString, # LPWSTR optional
Level: uint32, # DWORD
Buffer: ptr uint8 # BYTE*
): uint32 {.importc: "NetDfsSetInfo", stdcall, dynlib: "NETAPI32.dll".}pragma(lib, "netapi32");
extern(Windows)
uint NetDfsSetInfo(
const(wchar)* DfsEntryPath, // LPWSTR
const(wchar)* ServerName, // LPWSTR optional
const(wchar)* ShareName, // LPWSTR optional
uint Level, // DWORD
ubyte* Buffer // BYTE*
);ccall((:NetDfsSetInfo, "NETAPI32.dll"), stdcall, UInt32,
(Cwstring, Cwstring, Cwstring, UInt32, Ptr{UInt8}),
DfsEntryPath, ServerName, ShareName, Level, Buffer)
# DfsEntryPath : LPWSTR -> Cwstring
# ServerName : LPWSTR optional -> Cwstring
# ShareName : LPWSTR optional -> Cwstring
# Level : DWORD -> UInt32
# Buffer : BYTE* -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t NetDfsSetInfo(
const uint16_t* DfsEntryPath,
const uint16_t* ServerName,
const uint16_t* ShareName,
uint32_t Level,
uint8_t* Buffer);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.NetDfsSetInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)
-- DfsEntryPath : LPWSTR
-- ServerName : LPWSTR optional
-- ShareName : LPWSTR optional
-- Level : DWORD
-- Buffer : BYTE*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const NetDfsSetInfo = lib.func('__stdcall', 'NetDfsSetInfo', 'uint32_t', ['str16', 'str16', 'str16', 'uint32_t', 'uint8_t *']);
// NetDfsSetInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)
// DfsEntryPath : LPWSTR -> 'str16'
// ServerName : LPWSTR optional -> 'str16'
// ShareName : LPWSTR optional -> 'str16'
// Level : DWORD -> 'uint32_t'
// Buffer : BYTE* -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NETAPI32.dll", {
NetDfsSetInfo: { parameters: ["buffer", "buffer", "buffer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.NetDfsSetInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer)
// DfsEntryPath : LPWSTR -> "buffer"
// ServerName : LPWSTR optional -> "buffer"
// ShareName : LPWSTR optional -> "buffer"
// Level : DWORD -> "u32"
// Buffer : BYTE* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t NetDfsSetInfo(
const uint16_t* DfsEntryPath,
const uint16_t* ServerName,
const uint16_t* ShareName,
uint32_t Level,
uint8_t* Buffer);
C, "NETAPI32.dll");
// $ffi->NetDfsSetInfo(DfsEntryPath, ServerName, ShareName, Level, Buffer);
// DfsEntryPath : LPWSTR
// ServerName : LPWSTR optional
// ShareName : LPWSTR optional
// Level : DWORD
// Buffer : BYTE*
// 構造体/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 Netapi32 extends StdCallLibrary {
Netapi32 INSTANCE = Native.load("netapi32", Netapi32.class);
int NetDfsSetInfo(
WString DfsEntryPath, // LPWSTR
WString ServerName, // LPWSTR optional
WString ShareName, // LPWSTR optional
int Level, // DWORD
byte[] Buffer // BYTE*
);
}@[Link("netapi32")]
lib LibNETAPI32
fun NetDfsSetInfo = NetDfsSetInfo(
DfsEntryPath : UInt16*, # LPWSTR
ServerName : UInt16*, # LPWSTR optional
ShareName : UInt16*, # LPWSTR optional
Level : UInt32, # DWORD
Buffer : UInt8* # BYTE*
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NetDfsSetInfoNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Uint8>);
typedef NetDfsSetInfoDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Uint8>);
final NetDfsSetInfo = DynamicLibrary.open('NETAPI32.dll')
.lookupFunction<NetDfsSetInfoNative, NetDfsSetInfoDart>('NetDfsSetInfo');
// DfsEntryPath : LPWSTR -> Pointer<Utf16>
// ServerName : LPWSTR optional -> Pointer<Utf16>
// ShareName : LPWSTR optional -> Pointer<Utf16>
// Level : DWORD -> Uint32
// Buffer : BYTE* -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NetDfsSetInfo(
DfsEntryPath: PWideChar; // LPWSTR
ServerName: PWideChar; // LPWSTR optional
ShareName: PWideChar; // LPWSTR optional
Level: DWORD; // DWORD
Buffer: Pointer // BYTE*
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetDfsSetInfo';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NetDfsSetInfo"
c_NetDfsSetInfo :: CWString -> CWString -> CWString -> Word32 -> Ptr Word8 -> IO Word32
-- DfsEntryPath : LPWSTR -> CWString
-- ServerName : LPWSTR optional -> CWString
-- ShareName : LPWSTR optional -> CWString
-- Level : DWORD -> Word32
-- Buffer : BYTE* -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let netdfssetinfo =
foreign "NetDfsSetInfo"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint8_t) @-> returning uint32_t)
(* DfsEntryPath : LPWSTR -> (ptr uint16_t) *)
(* ServerName : LPWSTR optional -> (ptr uint16_t) *)
(* ShareName : LPWSTR optional -> (ptr uint16_t) *)
(* Level : DWORD -> uint32_t *)
(* Buffer : BYTE* -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)
(cffi:defcfun ("NetDfsSetInfo" net-dfs-set-info :convention :stdcall) :uint32
(dfs-entry-path (:string :encoding :utf-16le)) ; LPWSTR
(server-name (:string :encoding :utf-16le)) ; LPWSTR optional
(share-name (:string :encoding :utf-16le)) ; LPWSTR optional
(level :uint32) ; DWORD
(buffer :pointer)) ; BYTE*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NetDfsSetInfo = Win32::API::More->new('NETAPI32',
'DWORD NetDfsSetInfo(LPCWSTR DfsEntryPath, LPCWSTR ServerName, LPCWSTR ShareName, DWORD Level, LPVOID Buffer)');
# my $ret = $NetDfsSetInfo->Call($DfsEntryPath, $ServerName, $ShareName, $Level, $Buffer);
# DfsEntryPath : LPWSTR -> LPCWSTR
# ServerName : LPWSTR optional -> LPCWSTR
# ShareName : LPWSTR optional -> LPCWSTR
# Level : DWORD -> DWORD
# Buffer : BYTE* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。