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

NetDfsRemoveStdRoot

関数
スタンドアロンDFS名前空間のルートを削除する。
DLLNETAPI32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD NetDfsRemoveStdRoot(
    LPWSTR ServerName,
    LPWSTR RootShare,
    DWORD Flags   // optional
);

パラメーター

名前方向
ServerNameLPWSTRin
RootShareLPWSTRin
FlagsDWORDoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD NetDfsRemoveStdRoot(
    LPWSTR ServerName,
    LPWSTR RootShare,
    DWORD Flags   // optional
);
[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetDfsRemoveStdRoot(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerName,   // LPWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string RootShare,   // LPWSTR
    uint Flags   // DWORD optional
);
<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetDfsRemoveStdRoot(
    <MarshalAs(UnmanagedType.LPWStr)> ServerName As String,   ' LPWSTR
    <MarshalAs(UnmanagedType.LPWStr)> RootShare As String,   ' LPWSTR
    Flags As UInteger   ' DWORD optional
) As UInteger
End Function
' ServerName : LPWSTR
' RootShare : LPWSTR
' Flags : DWORD optional
Declare PtrSafe Function NetDfsRemoveStdRoot Lib "netapi32" ( _
    ByVal ServerName As LongPtr, _
    ByVal RootShare 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

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

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

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetDfsRemoveStdRoot = netapi32.NewProc("NetDfsRemoveStdRoot")
)

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