ホーム › Storage.DistributedFileSystem › NetDfsRemoveFtRootForced
NetDfsRemoveFtRootForced
関数フォールトトレラントなDFSルートを強制的に削除する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetDfsRemoveFtRootForced(
LPWSTR DomainName,
LPWSTR ServerName,
LPWSTR RootShare,
LPWSTR FtDfsName,
DWORD Flags // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| DomainName | LPWSTR | in | 対象FT-DFSが属するドメイン名を示すワイド文字列。 |
| ServerName | LPWSTR | in | 削除対象FT-DFSルートのサーバー名を示すワイド文字列。 |
| RootShare | LPWSTR | in | 削除対象ルートの共有名を示すワイド文字列。 |
| FtDfsName | LPWSTR | in | 削除対象のFT-DFS名を示すワイド文字列。 |
| Flags | DWORD | optional | 削除動作を制御するフラグ。サーバー応答不能時でも強制削除する。 |
戻り値の型: 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 // DWORDfunction 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)。const std = @import("std");
extern "netapi32" fn NetDfsRemoveFtRootForced(
DomainName: [*c]const u16, // LPWSTR
ServerName: [*c]const u16, // LPWSTR
RootShare: [*c]const u16, // LPWSTR
FtDfsName: [*c]const u16, // LPWSTR
Flags: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) u32;proc NetDfsRemoveFtRootForced(
DomainName: WideCString, # LPWSTR
ServerName: WideCString, # LPWSTR
RootShare: WideCString, # LPWSTR
FtDfsName: WideCString, # LPWSTR
Flags: uint32 # DWORD optional
): uint32 {.importc: "NetDfsRemoveFtRootForced", stdcall, dynlib: "NETAPI32.dll".}pragma(lib, "netapi32");
extern(Windows)
uint NetDfsRemoveFtRootForced(
const(wchar)* DomainName, // LPWSTR
const(wchar)* ServerName, // LPWSTR
const(wchar)* RootShare, // LPWSTR
const(wchar)* FtDfsName, // LPWSTR
uint Flags // DWORD optional
);ccall((:NetDfsRemoveFtRootForced, "NETAPI32.dll"), stdcall, UInt32,
(Cwstring, Cwstring, Cwstring, Cwstring, UInt32),
DomainName, ServerName, RootShare, FtDfsName, Flags)
# DomainName : LPWSTR -> Cwstring
# ServerName : LPWSTR -> Cwstring
# RootShare : LPWSTR -> Cwstring
# FtDfsName : LPWSTR -> Cwstring
# Flags : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t NetDfsRemoveFtRootForced(
const uint16_t* DomainName,
const uint16_t* ServerName,
const uint16_t* RootShare,
const uint16_t* FtDfsName,
uint32_t Flags);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.NetDfsRemoveFtRootForced(DomainName, ServerName, RootShare, FtDfsName, Flags)
-- DomainName : LPWSTR
-- ServerName : LPWSTR
-- RootShare : LPWSTR
-- FtDfsName : LPWSTR
-- Flags : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const NetDfsRemoveFtRootForced = lib.func('__stdcall', 'NetDfsRemoveFtRootForced', 'uint32_t', ['str16', 'str16', 'str16', 'str16', 'uint32_t']);
// NetDfsRemoveFtRootForced(DomainName, ServerName, RootShare, FtDfsName, Flags)
// DomainName : LPWSTR -> 'str16'
// ServerName : LPWSTR -> 'str16'
// RootShare : LPWSTR -> 'str16'
// FtDfsName : LPWSTR -> 'str16'
// Flags : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NETAPI32.dll", {
NetDfsRemoveFtRootForced: { parameters: ["buffer", "buffer", "buffer", "buffer", "u32"], result: "u32" },
});
// lib.symbols.NetDfsRemoveFtRootForced(DomainName, ServerName, RootShare, FtDfsName, Flags)
// DomainName : LPWSTR -> "buffer"
// ServerName : LPWSTR -> "buffer"
// RootShare : LPWSTR -> "buffer"
// FtDfsName : LPWSTR -> "buffer"
// Flags : DWORD optional -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t NetDfsRemoveFtRootForced(
const uint16_t* DomainName,
const uint16_t* ServerName,
const uint16_t* RootShare,
const uint16_t* FtDfsName,
uint32_t Flags);
C, "NETAPI32.dll");
// $ffi->NetDfsRemoveFtRootForced(DomainName, ServerName, RootShare, FtDfsName, Flags);
// DomainName : LPWSTR
// ServerName : LPWSTR
// RootShare : LPWSTR
// FtDfsName : LPWSTR
// Flags : DWORD optional
// 構造体/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 NetDfsRemoveFtRootForced(
WString DomainName, // LPWSTR
WString ServerName, // LPWSTR
WString RootShare, // LPWSTR
WString FtDfsName, // LPWSTR
int Flags // DWORD optional
);
}@[Link("netapi32")]
lib LibNETAPI32
fun NetDfsRemoveFtRootForced = NetDfsRemoveFtRootForced(
DomainName : UInt16*, # LPWSTR
ServerName : UInt16*, # LPWSTR
RootShare : UInt16*, # LPWSTR
FtDfsName : UInt16*, # LPWSTR
Flags : UInt32 # DWORD optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NetDfsRemoveFtRootForcedNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32);
typedef NetDfsRemoveFtRootForcedDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int);
final NetDfsRemoveFtRootForced = DynamicLibrary.open('NETAPI32.dll')
.lookupFunction<NetDfsRemoveFtRootForcedNative, NetDfsRemoveFtRootForcedDart>('NetDfsRemoveFtRootForced');
// DomainName : LPWSTR -> Pointer<Utf16>
// ServerName : LPWSTR -> Pointer<Utf16>
// RootShare : LPWSTR -> Pointer<Utf16>
// FtDfsName : LPWSTR -> Pointer<Utf16>
// Flags : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NetDfsRemoveFtRootForced"
c_NetDfsRemoveFtRootForced :: CWString -> CWString -> CWString -> CWString -> Word32 -> IO Word32
-- DomainName : LPWSTR -> CWString
-- ServerName : LPWSTR -> CWString
-- RootShare : LPWSTR -> CWString
-- FtDfsName : LPWSTR -> CWString
-- Flags : DWORD optional -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let netdfsremoveftrootforced =
foreign "NetDfsRemoveFtRootForced"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> returning uint32_t)
(* DomainName : LPWSTR -> (ptr uint16_t) *)
(* ServerName : LPWSTR -> (ptr uint16_t) *)
(* RootShare : LPWSTR -> (ptr uint16_t) *)
(* FtDfsName : LPWSTR -> (ptr uint16_t) *)
(* Flags : DWORD optional -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)
(cffi:defcfun ("NetDfsRemoveFtRootForced" net-dfs-remove-ft-root-forced :convention :stdcall) :uint32
(domain-name (:string :encoding :utf-16le)) ; LPWSTR
(server-name (:string :encoding :utf-16le)) ; LPWSTR
(root-share (:string :encoding :utf-16le)) ; LPWSTR
(ft-dfs-name (:string :encoding :utf-16le)) ; LPWSTR
(flags :uint32)) ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NetDfsRemoveFtRootForced = Win32::API::More->new('NETAPI32',
'DWORD NetDfsRemoveFtRootForced(LPCWSTR DomainName, LPCWSTR ServerName, LPCWSTR RootShare, LPCWSTR FtDfsName, DWORD Flags)');
# my $ret = $NetDfsRemoveFtRootForced->Call($DomainName, $ServerName, $RootShare, $FtDfsName, $Flags);
# DomainName : LPWSTR -> LPCWSTR
# ServerName : LPWSTR -> LPCWSTR
# RootShare : LPWSTR -> LPCWSTR
# FtDfsName : LPWSTR -> LPCWSTR
# Flags : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。