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