Win32 API 日本語リファレンス
ホームNetworkManagement.NetManagement › NetReplExportDirUnlock

NetReplExportDirUnlock

関数
エクスポート用ディレクトリのロックを解除する。
DLLNETAPI32.dll呼出規約winapi

シグネチャ

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

DWORD NetReplExportDirUnlock(
    LPCWSTR servername,
    LPCWSTR dirname,
    DWORD unlockforce
);

パラメーター

名前方向説明
servernameLPCWSTRin操作対象サーバー名。NULLでローカルコンピュータを指す。
dirnameLPCWSTRinロック解除するエクスポートディレクトリ名。
unlockforceDWORDin強制解除の方法を指定する(REPL_UNLOCK_NOFORCE/FORCE)。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

NetReplExportDirUnlock = ctypes.windll.netapi32.NetReplExportDirUnlock
NetReplExportDirUnlock.restype = wintypes.DWORD
NetReplExportDirUnlock.argtypes = [
    wintypes.LPCWSTR,  # servername : LPCWSTR
    wintypes.LPCWSTR,  # dirname : LPCWSTR
    wintypes.DWORD,  # unlockforce : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetReplExportDirUnlock = netapi32.NewProc("NetReplExportDirUnlock")
)

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

extern "netapi32" fn NetReplExportDirUnlock(
    servername: [*c]const u16, // LPCWSTR
    dirname: [*c]const u16, // LPCWSTR
    unlockforce: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
proc NetReplExportDirUnlock(
    servername: WideCString,  # LPCWSTR
    dirname: WideCString,  # LPCWSTR
    unlockforce: uint32  # DWORD
): uint32 {.importc: "NetReplExportDirUnlock", stdcall, dynlib: "NETAPI32.dll".}
pragma(lib, "netapi32");
extern(Windows)
uint NetReplExportDirUnlock(
    const(wchar)* servername,   // LPCWSTR
    const(wchar)* dirname,   // LPCWSTR
    uint unlockforce   // DWORD
);
ccall((:NetReplExportDirUnlock, "NETAPI32.dll"), stdcall, UInt32,
      (Cwstring, Cwstring, UInt32),
      servername, dirname, unlockforce)
# servername : LPCWSTR -> Cwstring
# dirname : LPCWSTR -> Cwstring
# unlockforce : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t NetReplExportDirUnlock(
    const uint16_t* servername,
    const uint16_t* dirname,
    uint32_t unlockforce);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.NetReplExportDirUnlock(servername, dirname, unlockforce)
-- servername : LPCWSTR
-- dirname : LPCWSTR
-- unlockforce : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const NetReplExportDirUnlock = lib.func('__stdcall', 'NetReplExportDirUnlock', 'uint32_t', ['str16', 'str16', 'uint32_t']);
// NetReplExportDirUnlock(servername, dirname, unlockforce)
// servername : LPCWSTR -> 'str16'
// dirname : LPCWSTR -> 'str16'
// unlockforce : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("NETAPI32.dll", {
  NetReplExportDirUnlock: { parameters: ["buffer", "buffer", "u32"], result: "u32" },
});
// lib.symbols.NetReplExportDirUnlock(servername, dirname, unlockforce)
// servername : LPCWSTR -> "buffer"
// dirname : LPCWSTR -> "buffer"
// unlockforce : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t NetReplExportDirUnlock(
    const uint16_t* servername,
    const uint16_t* dirname,
    uint32_t unlockforce);
C, "NETAPI32.dll");
// $ffi->NetReplExportDirUnlock(servername, dirname, unlockforce);
// servername : LPCWSTR
// dirname : LPCWSTR
// unlockforce : DWORD
// 構造体/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 NetReplExportDirUnlock(
        WString servername,   // LPCWSTR
        WString dirname,   // LPCWSTR
        int unlockforce   // DWORD
    );
}
@[Link("netapi32")]
lib LibNETAPI32
  fun NetReplExportDirUnlock = NetReplExportDirUnlock(
    servername : UInt16*,   # LPCWSTR
    dirname : UInt16*,   # LPCWSTR
    unlockforce : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef NetReplExportDirUnlockNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Uint32);
typedef NetReplExportDirUnlockDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int);
final NetReplExportDirUnlock = DynamicLibrary.open('NETAPI32.dll')
    .lookupFunction<NetReplExportDirUnlockNative, NetReplExportDirUnlockDart>('NetReplExportDirUnlock');
// servername : LPCWSTR -> Pointer<Utf16>
// dirname : LPCWSTR -> Pointer<Utf16>
// unlockforce : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function NetReplExportDirUnlock(
  servername: PWideChar;   // LPCWSTR
  dirname: PWideChar;   // LPCWSTR
  unlockforce: DWORD   // DWORD
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'NetReplExportDirUnlock';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "NetReplExportDirUnlock"
  c_NetReplExportDirUnlock :: CWString -> CWString -> Word32 -> IO Word32
-- servername : LPCWSTR -> CWString
-- dirname : LPCWSTR -> CWString
-- unlockforce : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let netreplexportdirunlock =
  foreign "NetReplExportDirUnlock"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> returning uint32_t)
(* servername : LPCWSTR -> (ptr uint16_t) *)
(* dirname : LPCWSTR -> (ptr uint16_t) *)
(* unlockforce : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)

(cffi:defcfun ("NetReplExportDirUnlock" net-repl-export-dir-unlock :convention :stdcall) :uint32
  (servername (:string :encoding :utf-16le))   ; LPCWSTR
  (dirname (:string :encoding :utf-16le))   ; LPCWSTR
  (unlockforce :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $NetReplExportDirUnlock = Win32::API::More->new('NETAPI32',
    'DWORD NetReplExportDirUnlock(LPCWSTR servername, LPCWSTR dirname, DWORD unlockforce)');
# my $ret = $NetReplExportDirUnlock->Call($servername, $dirname, $unlockforce);
# servername : LPCWSTR -> LPCWSTR
# dirname : LPCWSTR -> LPCWSTR
# unlockforce : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。