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

WlanDisconnect

関数
無線LANインターフェイスの現在の接続を切断する。
DLLwlanapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD WlanDisconnect(
    HANDLE hClientHandle,
    const GUID* pInterfaceGuid,
    void* pReserved   // optional
);

パラメーター

名前方向説明
hClientHandleHANDLEinWlanOpenHandleで取得したクライアントセッションのハンドル。
pInterfaceGuidGUID*in切断する無線LANインターフェースのGUIDへのポインター。
pReservedvoid*optional予約領域。NULLを指定する必要がある。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD WlanDisconnect(
    HANDLE hClientHandle,
    const GUID* pInterfaceGuid,
    void* pReserved   // optional
);
[DllImport("wlanapi.dll", ExactSpelling = true)]
static extern uint WlanDisconnect(
    IntPtr hClientHandle,   // HANDLE
    ref Guid pInterfaceGuid,   // GUID*
    IntPtr pReserved   // void* optional
);
<DllImport("wlanapi.dll", ExactSpelling:=True)>
Public Shared Function WlanDisconnect(
    hClientHandle As IntPtr,   ' HANDLE
    ByRef pInterfaceGuid As Guid,   ' GUID*
    pReserved As IntPtr   ' void* optional
) As UInteger
End Function
' hClientHandle : HANDLE
' pInterfaceGuid : GUID*
' pReserved : void* optional
Declare PtrSafe Function WlanDisconnect Lib "wlanapi" ( _
    ByVal hClientHandle As LongPtr, _
    ByVal pInterfaceGuid As LongPtr, _
    ByVal pReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WlanDisconnect = ctypes.windll.wlanapi.WlanDisconnect
WlanDisconnect.restype = wintypes.DWORD
WlanDisconnect.argtypes = [
    wintypes.HANDLE,  # hClientHandle : HANDLE
    ctypes.c_void_p,  # pInterfaceGuid : GUID*
    ctypes.POINTER(None),  # pReserved : void* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wlanapi.dll')
WlanDisconnect = Fiddle::Function.new(
  lib['WlanDisconnect'],
  [
    Fiddle::TYPE_VOIDP,  # hClientHandle : HANDLE
    Fiddle::TYPE_VOIDP,  # pInterfaceGuid : GUID*
    Fiddle::TYPE_VOIDP,  # pReserved : void* optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wlanapi")]
extern "system" {
    fn WlanDisconnect(
        hClientHandle: *mut core::ffi::c_void,  // HANDLE
        pInterfaceGuid: *const GUID,  // GUID*
        pReserved: *mut ()  // void* optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wlanapi.dll")]
public static extern uint WlanDisconnect(IntPtr hClientHandle, ref Guid pInterfaceGuid, IntPtr pReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wlanapi_WlanDisconnect' -Namespace Win32 -PassThru
# $api::WlanDisconnect(hClientHandle, pInterfaceGuid, pReserved)
#uselib "wlanapi.dll"
#func global WlanDisconnect "WlanDisconnect" sptr, sptr, sptr
; WlanDisconnect hClientHandle, varptr(pInterfaceGuid), pReserved   ; 戻り値は stat
; hClientHandle : HANDLE -> "sptr"
; pInterfaceGuid : GUID* -> "sptr"
; pReserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wlanapi.dll"
#cfunc global WlanDisconnect "WlanDisconnect" sptr, var, sptr
; res = WlanDisconnect(hClientHandle, pInterfaceGuid, pReserved)
; hClientHandle : HANDLE -> "sptr"
; pInterfaceGuid : GUID* -> "var"
; pReserved : void* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD WlanDisconnect(HANDLE hClientHandle, GUID* pInterfaceGuid, void* pReserved)
#uselib "wlanapi.dll"
#cfunc global WlanDisconnect "WlanDisconnect" intptr, var, intptr
; res = WlanDisconnect(hClientHandle, pInterfaceGuid, pReserved)
; hClientHandle : HANDLE -> "intptr"
; pInterfaceGuid : GUID* -> "var"
; pReserved : void* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wlanapi = windows.NewLazySystemDLL("wlanapi.dll")
	procWlanDisconnect = wlanapi.NewProc("WlanDisconnect")
)

// hClientHandle (HANDLE), pInterfaceGuid (GUID*), pReserved (void* optional)
r1, _, err := procWlanDisconnect.Call(
	uintptr(hClientHandle),
	uintptr(pInterfaceGuid),
	uintptr(pReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WlanDisconnect(
  hClientHandle: THandle;   // HANDLE
  pInterfaceGuid: PGUID;   // GUID*
  pReserved: Pointer   // void* optional
): DWORD; stdcall;
  external 'wlanapi.dll' name 'WlanDisconnect';
result := DllCall("wlanapi\WlanDisconnect"
    , "Ptr", hClientHandle   ; HANDLE
    , "Ptr", pInterfaceGuid   ; GUID*
    , "Ptr", pReserved   ; void* optional
    , "UInt")   ; return: DWORD
●WlanDisconnect(hClientHandle, pInterfaceGuid, pReserved) = DLL("wlanapi.dll", "dword WlanDisconnect(void*, void*, void*)")
# 呼び出し: WlanDisconnect(hClientHandle, pInterfaceGuid, pReserved)
# hClientHandle : HANDLE -> "void*"
# pInterfaceGuid : GUID* -> "void*"
# pReserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef WlanDisconnectNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef WlanDisconnectDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
final WlanDisconnect = DynamicLibrary.open('wlanapi.dll')
    .lookupFunction<WlanDisconnectNative, WlanDisconnectDart>('WlanDisconnect');
// hClientHandle : HANDLE -> Pointer<Void>
// pInterfaceGuid : GUID* -> Pointer<Void>
// pReserved : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WlanDisconnect(
  hClientHandle: THandle;   // HANDLE
  pInterfaceGuid: PGUID;   // GUID*
  pReserved: Pointer   // void* optional
): DWORD; stdcall;
  external 'wlanapi.dll' name 'WlanDisconnect';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WlanDisconnect"
  c_WlanDisconnect :: Ptr () -> Ptr () -> Ptr () -> IO Word32
-- hClientHandle : HANDLE -> Ptr ()
-- pInterfaceGuid : GUID* -> Ptr ()
-- pReserved : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wlandisconnect =
  foreign "WlanDisconnect"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* hClientHandle : HANDLE -> (ptr void) *)
(* pInterfaceGuid : GUID* -> (ptr void) *)
(* pReserved : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wlanapi (t "wlanapi.dll"))
(cffi:use-foreign-library wlanapi)

(cffi:defcfun ("WlanDisconnect" wlan-disconnect :convention :stdcall) :uint32
  (h-client-handle :pointer)   ; HANDLE
  (p-interface-guid :pointer)   ; GUID*
  (p-reserved :pointer))   ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WlanDisconnect = Win32::API::More->new('wlanapi',
    'DWORD WlanDisconnect(HANDLE hClientHandle, LPVOID pInterfaceGuid, LPVOID pReserved)');
# my $ret = $WlanDisconnect->Call($hClientHandle, $pInterfaceGuid, $pReserved);
# hClientHandle : HANDLE -> HANDLE
# pInterfaceGuid : GUID* -> LPVOID
# pReserved : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。