ホーム › NetworkManagement.NetManagement › NetReplExportDirDel
NetReplExportDirDel
関数レプリケーションのエクスポート用ディレクトリを削除する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetReplExportDirDel(
LPCWSTR servername,
LPCWSTR dirname
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| servername | LPCWSTR | in | 操作対象サーバー名。NULLでローカルコンピュータを指す。 |
| dirname | LPCWSTR | in | 削除するエクスポートディレクトリ名。 |
戻り値の型: DWORD
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
DWORD NetReplExportDirDel(
LPCWSTR servername,
LPCWSTR dirname
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetReplExportDirDel(
[MarshalAs(UnmanagedType.LPWStr)] string servername, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string dirname // LPCWSTR
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetReplExportDirDel(
<MarshalAs(UnmanagedType.LPWStr)> servername As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> dirname As String ' LPCWSTR
) As UInteger
End Function' servername : LPCWSTR
' dirname : LPCWSTR
Declare PtrSafe Function NetReplExportDirDel Lib "netapi32" ( _
ByVal servername As LongPtr, _
ByVal dirname As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NetReplExportDirDel = ctypes.windll.netapi32.NetReplExportDirDel
NetReplExportDirDel.restype = wintypes.DWORD
NetReplExportDirDel.argtypes = [
wintypes.LPCWSTR, # servername : LPCWSTR
wintypes.LPCWSTR, # dirname : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
NetReplExportDirDel = Fiddle::Function.new(
lib['NetReplExportDirDel'],
[
Fiddle::TYPE_VOIDP, # servername : LPCWSTR
Fiddle::TYPE_VOIDP, # dirname : LPCWSTR
],
-Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn NetReplExportDirDel(
servername: *const u16, // LPCWSTR
dirname: *const u16 // LPCWSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetReplExportDirDel([MarshalAs(UnmanagedType.LPWStr)] string servername, [MarshalAs(UnmanagedType.LPWStr)] string dirname);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetReplExportDirDel' -Namespace Win32 -PassThru
# $api::NetReplExportDirDel(servername, dirname)#uselib "NETAPI32.dll"
#func global NetReplExportDirDel "NetReplExportDirDel" sptr, sptr
; NetReplExportDirDel servername, dirname ; 戻り値は stat
; servername : LPCWSTR -> "sptr"
; dirname : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "NETAPI32.dll"
#cfunc global NetReplExportDirDel "NetReplExportDirDel" wstr, wstr
; res = NetReplExportDirDel(servername, dirname)
; servername : LPCWSTR -> "wstr"
; dirname : LPCWSTR -> "wstr"; DWORD NetReplExportDirDel(LPCWSTR servername, LPCWSTR dirname)
#uselib "NETAPI32.dll"
#cfunc global NetReplExportDirDel "NetReplExportDirDel" wstr, wstr
; res = NetReplExportDirDel(servername, dirname)
; servername : LPCWSTR -> "wstr"
; dirname : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procNetReplExportDirDel = netapi32.NewProc("NetReplExportDirDel")
)
// servername (LPCWSTR), dirname (LPCWSTR)
r1, _, err := procNetReplExportDirDel.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(servername))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(dirname))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction NetReplExportDirDel(
servername: PWideChar; // LPCWSTR
dirname: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetReplExportDirDel';result := DllCall("NETAPI32\NetReplExportDirDel"
, "WStr", servername ; LPCWSTR
, "WStr", dirname ; LPCWSTR
, "UInt") ; return: DWORD●NetReplExportDirDel(servername, dirname) = DLL("NETAPI32.dll", "dword NetReplExportDirDel(char*, char*)")
# 呼び出し: NetReplExportDirDel(servername, dirname)
# servername : LPCWSTR -> "char*"
# dirname : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "netapi32" fn NetReplExportDirDel(
servername: [*c]const u16, // LPCWSTR
dirname: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) u32;proc NetReplExportDirDel(
servername: WideCString, # LPCWSTR
dirname: WideCString # LPCWSTR
): uint32 {.importc: "NetReplExportDirDel", stdcall, dynlib: "NETAPI32.dll".}pragma(lib, "netapi32");
extern(Windows)
uint NetReplExportDirDel(
const(wchar)* servername, // LPCWSTR
const(wchar)* dirname // LPCWSTR
);ccall((:NetReplExportDirDel, "NETAPI32.dll"), stdcall, UInt32,
(Cwstring, Cwstring),
servername, dirname)
# servername : LPCWSTR -> Cwstring
# dirname : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t NetReplExportDirDel(
const uint16_t* servername,
const uint16_t* dirname);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.NetReplExportDirDel(servername, dirname)
-- servername : LPCWSTR
-- dirname : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const NetReplExportDirDel = lib.func('__stdcall', 'NetReplExportDirDel', 'uint32_t', ['str16', 'str16']);
// NetReplExportDirDel(servername, dirname)
// servername : LPCWSTR -> 'str16'
// dirname : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NETAPI32.dll", {
NetReplExportDirDel: { parameters: ["buffer", "buffer"], result: "u32" },
});
// lib.symbols.NetReplExportDirDel(servername, dirname)
// servername : LPCWSTR -> "buffer"
// dirname : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t NetReplExportDirDel(
const uint16_t* servername,
const uint16_t* dirname);
C, "NETAPI32.dll");
// $ffi->NetReplExportDirDel(servername, dirname);
// servername : LPCWSTR
// dirname : LPCWSTR
// 構造体/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 NetReplExportDirDel(
WString servername, // LPCWSTR
WString dirname // LPCWSTR
);
}@[Link("netapi32")]
lib LibNETAPI32
fun NetReplExportDirDel = NetReplExportDirDel(
servername : UInt16*, # LPCWSTR
dirname : UInt16* # LPCWSTR
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NetReplExportDirDelNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>);
typedef NetReplExportDirDelDart = int Function(Pointer<Utf16>, Pointer<Utf16>);
final NetReplExportDirDel = DynamicLibrary.open('NETAPI32.dll')
.lookupFunction<NetReplExportDirDelNative, NetReplExportDirDelDart>('NetReplExportDirDel');
// servername : LPCWSTR -> Pointer<Utf16>
// dirname : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NetReplExportDirDel(
servername: PWideChar; // LPCWSTR
dirname: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetReplExportDirDel';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NetReplExportDirDel"
c_NetReplExportDirDel :: CWString -> CWString -> IO Word32
-- servername : LPCWSTR -> CWString
-- dirname : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let netreplexportdirdel =
foreign "NetReplExportDirDel"
((ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* servername : LPCWSTR -> (ptr uint16_t) *)
(* dirname : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)
(cffi:defcfun ("NetReplExportDirDel" net-repl-export-dir-del :convention :stdcall) :uint32
(servername (:string :encoding :utf-16le)) ; LPCWSTR
(dirname (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NetReplExportDirDel = Win32::API::More->new('NETAPI32',
'DWORD NetReplExportDirDel(LPCWSTR servername, LPCWSTR dirname)');
# my $ret = $NetReplExportDirDel->Call($servername, $dirname);
# servername : LPCWSTR -> LPCWSTR
# dirname : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。