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

NetReplExportDirUnlock

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

シグネチャ

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

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

パラメーター

名前方向
servernameLPCWSTRin
dirnameLPCWSTRin
unlockforceDWORDin

戻り値の型: 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)。