ホーム › Storage.FileSystem › NetSessionDel
NetSessionDel
関数指定したネットワークセッションを切断する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetSessionDel(
LPWSTR servername, // optional
LPWSTR UncClientName, // optional
LPWSTR username // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| servername | LPWSTR | inoptional |
| UncClientName | LPWSTR | inoptional |
| username | LPWSTR | inoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
DWORD NetSessionDel(
LPWSTR servername, // optional
LPWSTR UncClientName, // optional
LPWSTR username // optional
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetSessionDel(
[MarshalAs(UnmanagedType.LPWStr)] string servername, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string UncClientName, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string username // LPWSTR optional
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetSessionDel(
<MarshalAs(UnmanagedType.LPWStr)> servername As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> UncClientName As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> username As String ' LPWSTR optional
) As UInteger
End Function' servername : LPWSTR optional
' UncClientName : LPWSTR optional
' username : LPWSTR optional
Declare PtrSafe Function NetSessionDel Lib "netapi32" ( _
ByVal servername As LongPtr, _
ByVal UncClientName As LongPtr, _
ByVal username As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NetSessionDel = ctypes.windll.netapi32.NetSessionDel
NetSessionDel.restype = wintypes.DWORD
NetSessionDel.argtypes = [
wintypes.LPCWSTR, # servername : LPWSTR optional
wintypes.LPCWSTR, # UncClientName : LPWSTR optional
wintypes.LPCWSTR, # username : LPWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
NetSessionDel = Fiddle::Function.new(
lib['NetSessionDel'],
[
Fiddle::TYPE_VOIDP, # servername : LPWSTR optional
Fiddle::TYPE_VOIDP, # UncClientName : LPWSTR optional
Fiddle::TYPE_VOIDP, # username : LPWSTR optional
],
-Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn NetSessionDel(
servername: *mut u16, // LPWSTR optional
UncClientName: *mut u16, // LPWSTR optional
username: *mut u16 // LPWSTR optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetSessionDel([MarshalAs(UnmanagedType.LPWStr)] string servername, [MarshalAs(UnmanagedType.LPWStr)] string UncClientName, [MarshalAs(UnmanagedType.LPWStr)] string username);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetSessionDel' -Namespace Win32 -PassThru
# $api::NetSessionDel(servername, UncClientName, username)#uselib "NETAPI32.dll"
#func global NetSessionDel "NetSessionDel" sptr, sptr, sptr
; NetSessionDel servername, UncClientName, username ; 戻り値は stat
; servername : LPWSTR optional -> "sptr"
; UncClientName : LPWSTR optional -> "sptr"
; username : LPWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "NETAPI32.dll"
#cfunc global NetSessionDel "NetSessionDel" wstr, wstr, wstr
; res = NetSessionDel(servername, UncClientName, username)
; servername : LPWSTR optional -> "wstr"
; UncClientName : LPWSTR optional -> "wstr"
; username : LPWSTR optional -> "wstr"; DWORD NetSessionDel(LPWSTR servername, LPWSTR UncClientName, LPWSTR username)
#uselib "NETAPI32.dll"
#cfunc global NetSessionDel "NetSessionDel" wstr, wstr, wstr
; res = NetSessionDel(servername, UncClientName, username)
; servername : LPWSTR optional -> "wstr"
; UncClientName : LPWSTR optional -> "wstr"
; username : LPWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procNetSessionDel = netapi32.NewProc("NetSessionDel")
)
// servername (LPWSTR optional), UncClientName (LPWSTR optional), username (LPWSTR optional)
r1, _, err := procNetSessionDel.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(servername))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(UncClientName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(username))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction NetSessionDel(
servername: PWideChar; // LPWSTR optional
UncClientName: PWideChar; // LPWSTR optional
username: PWideChar // LPWSTR optional
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetSessionDel';result := DllCall("NETAPI32\NetSessionDel"
, "WStr", servername ; LPWSTR optional
, "WStr", UncClientName ; LPWSTR optional
, "WStr", username ; LPWSTR optional
, "UInt") ; return: DWORD●NetSessionDel(servername, UncClientName, username) = DLL("NETAPI32.dll", "dword NetSessionDel(char*, char*, char*)")
# 呼び出し: NetSessionDel(servername, UncClientName, username)
# servername : LPWSTR optional -> "char*"
# UncClientName : LPWSTR optional -> "char*"
# username : LPWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。