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

NetDfsRemoveFtRootForced

関数
フォールトトレラントなDFSルートを強制的に削除する。
DLLNETAPI32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD NetDfsRemoveFtRootForced(
    LPWSTR DomainName,
    LPWSTR ServerName,
    LPWSTR RootShare,
    LPWSTR FtDfsName,
    DWORD Flags   // optional
);

パラメーター

名前方向
DomainNameLPWSTRin
ServerNameLPWSTRin
RootShareLPWSTRin
FtDfsNameLPWSTRin
FlagsDWORDoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

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

NetDfsRemoveFtRootForced = ctypes.windll.netapi32.NetDfsRemoveFtRootForced
NetDfsRemoveFtRootForced.restype = wintypes.DWORD
NetDfsRemoveFtRootForced.argtypes = [
    wintypes.LPCWSTR,  # DomainName : LPWSTR
    wintypes.LPCWSTR,  # ServerName : LPWSTR
    wintypes.LPCWSTR,  # RootShare : LPWSTR
    wintypes.LPCWSTR,  # FtDfsName : LPWSTR
    wintypes.DWORD,  # Flags : DWORD optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NETAPI32.dll')
NetDfsRemoveFtRootForced = Fiddle::Function.new(
  lib['NetDfsRemoveFtRootForced'],
  [
    Fiddle::TYPE_VOIDP,  # DomainName : LPWSTR
    Fiddle::TYPE_VOIDP,  # ServerName : LPWSTR
    Fiddle::TYPE_VOIDP,  # RootShare : LPWSTR
    Fiddle::TYPE_VOIDP,  # FtDfsName : LPWSTR
    -Fiddle::TYPE_INT,  # Flags : DWORD optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "netapi32")]
extern "system" {
    fn NetDfsRemoveFtRootForced(
        DomainName: *mut u16,  // LPWSTR
        ServerName: *mut u16,  // LPWSTR
        RootShare: *mut u16,  // LPWSTR
        FtDfsName: *mut u16,  // LPWSTR
        Flags: u32  // DWORD optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetDfsRemoveFtRootForced([MarshalAs(UnmanagedType.LPWStr)] string DomainName, [MarshalAs(UnmanagedType.LPWStr)] string ServerName, [MarshalAs(UnmanagedType.LPWStr)] string RootShare, [MarshalAs(UnmanagedType.LPWStr)] string FtDfsName, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetDfsRemoveFtRootForced' -Namespace Win32 -PassThru
# $api::NetDfsRemoveFtRootForced(DomainName, ServerName, RootShare, FtDfsName, Flags)
#uselib "NETAPI32.dll"
#func global NetDfsRemoveFtRootForced "NetDfsRemoveFtRootForced" sptr, sptr, sptr, sptr, sptr
; NetDfsRemoveFtRootForced DomainName, ServerName, RootShare, FtDfsName, Flags   ; 戻り値は stat
; DomainName : LPWSTR -> "sptr"
; ServerName : LPWSTR -> "sptr"
; RootShare : LPWSTR -> "sptr"
; FtDfsName : LPWSTR -> "sptr"
; Flags : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "NETAPI32.dll"
#cfunc global NetDfsRemoveFtRootForced "NetDfsRemoveFtRootForced" wstr, wstr, wstr, wstr, int
; res = NetDfsRemoveFtRootForced(DomainName, ServerName, RootShare, FtDfsName, Flags)
; DomainName : LPWSTR -> "wstr"
; ServerName : LPWSTR -> "wstr"
; RootShare : LPWSTR -> "wstr"
; FtDfsName : LPWSTR -> "wstr"
; Flags : DWORD optional -> "int"
; DWORD NetDfsRemoveFtRootForced(LPWSTR DomainName, LPWSTR ServerName, LPWSTR RootShare, LPWSTR FtDfsName, DWORD Flags)
#uselib "NETAPI32.dll"
#cfunc global NetDfsRemoveFtRootForced "NetDfsRemoveFtRootForced" wstr, wstr, wstr, wstr, int
; res = NetDfsRemoveFtRootForced(DomainName, ServerName, RootShare, FtDfsName, Flags)
; DomainName : LPWSTR -> "wstr"
; ServerName : LPWSTR -> "wstr"
; RootShare : LPWSTR -> "wstr"
; FtDfsName : LPWSTR -> "wstr"
; Flags : DWORD optional -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetDfsRemoveFtRootForced = netapi32.NewProc("NetDfsRemoveFtRootForced")
)

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