ホーム › NetworkManagement.WiFi › WlanReasonCodeToString
WlanReasonCodeToString
関数WLANの理由コードを説明文字列に変換する。
シグネチャ
// wlanapi.dll
#include <windows.h>
DWORD WlanReasonCodeToString(
DWORD dwReasonCode,
DWORD dwBufferSize,
LPWSTR pStringBuffer,
void* pReserved // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dwReasonCode | DWORD | in | 文字列化する理由コード(WLAN_REASON_CODE)。 |
| dwBufferSize | DWORD | in | pStringBufferの容量を文字数で指定する。 |
| pStringBuffer | LPWSTR | in | 理由コードの説明文字列を受け取るバッファへのポインター。 |
| pReserved | void* | optional | 予約領域。NULLを指定する必要がある。 |
戻り値の型: DWORD
各言語での呼び出し定義
// wlanapi.dll
#include <windows.h>
DWORD WlanReasonCodeToString(
DWORD dwReasonCode,
DWORD dwBufferSize,
LPWSTR pStringBuffer,
void* pReserved // optional
);[DllImport("wlanapi.dll", ExactSpelling = true)]
static extern uint WlanReasonCodeToString(
uint dwReasonCode, // DWORD
uint dwBufferSize, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pStringBuffer, // LPWSTR
IntPtr pReserved // void* optional
);<DllImport("wlanapi.dll", ExactSpelling:=True)>
Public Shared Function WlanReasonCodeToString(
dwReasonCode As UInteger, ' DWORD
dwBufferSize As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pStringBuffer As String, ' LPWSTR
pReserved As IntPtr ' void* optional
) As UInteger
End Function' dwReasonCode : DWORD
' dwBufferSize : DWORD
' pStringBuffer : LPWSTR
' pReserved : void* optional
Declare PtrSafe Function WlanReasonCodeToString Lib "wlanapi" ( _
ByVal dwReasonCode As Long, _
ByVal dwBufferSize As Long, _
ByVal pStringBuffer 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
WlanReasonCodeToString = ctypes.windll.wlanapi.WlanReasonCodeToString
WlanReasonCodeToString.restype = wintypes.DWORD
WlanReasonCodeToString.argtypes = [
wintypes.DWORD, # dwReasonCode : DWORD
wintypes.DWORD, # dwBufferSize : DWORD
wintypes.LPCWSTR, # pStringBuffer : LPWSTR
ctypes.POINTER(None), # pReserved : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wlanapi.dll')
WlanReasonCodeToString = Fiddle::Function.new(
lib['WlanReasonCodeToString'],
[
-Fiddle::TYPE_INT, # dwReasonCode : DWORD
-Fiddle::TYPE_INT, # dwBufferSize : DWORD
Fiddle::TYPE_VOIDP, # pStringBuffer : LPWSTR
Fiddle::TYPE_VOIDP, # pReserved : void* optional
],
-Fiddle::TYPE_INT)#[link(name = "wlanapi")]
extern "system" {
fn WlanReasonCodeToString(
dwReasonCode: u32, // DWORD
dwBufferSize: u32, // DWORD
pStringBuffer: *mut u16, // LPWSTR
pReserved: *mut () // void* optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wlanapi.dll")]
public static extern uint WlanReasonCodeToString(uint dwReasonCode, uint dwBufferSize, [MarshalAs(UnmanagedType.LPWStr)] string pStringBuffer, IntPtr pReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wlanapi_WlanReasonCodeToString' -Namespace Win32 -PassThru
# $api::WlanReasonCodeToString(dwReasonCode, dwBufferSize, pStringBuffer, pReserved)#uselib "wlanapi.dll"
#func global WlanReasonCodeToString "WlanReasonCodeToString" sptr, sptr, sptr, sptr
; WlanReasonCodeToString dwReasonCode, dwBufferSize, pStringBuffer, pReserved ; 戻り値は stat
; dwReasonCode : DWORD -> "sptr"
; dwBufferSize : DWORD -> "sptr"
; pStringBuffer : LPWSTR -> "sptr"
; pReserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "wlanapi.dll"
#cfunc global WlanReasonCodeToString "WlanReasonCodeToString" int, int, wstr, sptr
; res = WlanReasonCodeToString(dwReasonCode, dwBufferSize, pStringBuffer, pReserved)
; dwReasonCode : DWORD -> "int"
; dwBufferSize : DWORD -> "int"
; pStringBuffer : LPWSTR -> "wstr"
; pReserved : void* optional -> "sptr"; DWORD WlanReasonCodeToString(DWORD dwReasonCode, DWORD dwBufferSize, LPWSTR pStringBuffer, void* pReserved)
#uselib "wlanapi.dll"
#cfunc global WlanReasonCodeToString "WlanReasonCodeToString" int, int, wstr, intptr
; res = WlanReasonCodeToString(dwReasonCode, dwBufferSize, pStringBuffer, pReserved)
; dwReasonCode : DWORD -> "int"
; dwBufferSize : DWORD -> "int"
; pStringBuffer : LPWSTR -> "wstr"
; pReserved : void* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wlanapi = windows.NewLazySystemDLL("wlanapi.dll")
procWlanReasonCodeToString = wlanapi.NewProc("WlanReasonCodeToString")
)
// dwReasonCode (DWORD), dwBufferSize (DWORD), pStringBuffer (LPWSTR), pReserved (void* optional)
r1, _, err := procWlanReasonCodeToString.Call(
uintptr(dwReasonCode),
uintptr(dwBufferSize),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pStringBuffer))),
uintptr(pReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction WlanReasonCodeToString(
dwReasonCode: DWORD; // DWORD
dwBufferSize: DWORD; // DWORD
pStringBuffer: PWideChar; // LPWSTR
pReserved: Pointer // void* optional
): DWORD; stdcall;
external 'wlanapi.dll' name 'WlanReasonCodeToString';result := DllCall("wlanapi\WlanReasonCodeToString"
, "UInt", dwReasonCode ; DWORD
, "UInt", dwBufferSize ; DWORD
, "WStr", pStringBuffer ; LPWSTR
, "Ptr", pReserved ; void* optional
, "UInt") ; return: DWORD●WlanReasonCodeToString(dwReasonCode, dwBufferSize, pStringBuffer, pReserved) = DLL("wlanapi.dll", "dword WlanReasonCodeToString(dword, dword, char*, void*)")
# 呼び出し: WlanReasonCodeToString(dwReasonCode, dwBufferSize, pStringBuffer, pReserved)
# dwReasonCode : DWORD -> "dword"
# dwBufferSize : DWORD -> "dword"
# pStringBuffer : LPWSTR -> "char*"
# pReserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wlanapi" fn WlanReasonCodeToString(
dwReasonCode: u32, // DWORD
dwBufferSize: u32, // DWORD
pStringBuffer: [*c]const u16, // LPWSTR
pReserved: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) u32;proc WlanReasonCodeToString(
dwReasonCode: uint32, # DWORD
dwBufferSize: uint32, # DWORD
pStringBuffer: WideCString, # LPWSTR
pReserved: pointer # void* optional
): uint32 {.importc: "WlanReasonCodeToString", stdcall, dynlib: "wlanapi.dll".}pragma(lib, "wlanapi");
extern(Windows)
uint WlanReasonCodeToString(
uint dwReasonCode, // DWORD
uint dwBufferSize, // DWORD
const(wchar)* pStringBuffer, // LPWSTR
void* pReserved // void* optional
);ccall((:WlanReasonCodeToString, "wlanapi.dll"), stdcall, UInt32,
(UInt32, UInt32, Cwstring, Ptr{Cvoid}),
dwReasonCode, dwBufferSize, pStringBuffer, pReserved)
# dwReasonCode : DWORD -> UInt32
# dwBufferSize : DWORD -> UInt32
# pStringBuffer : LPWSTR -> Cwstring
# pReserved : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t WlanReasonCodeToString(
uint32_t dwReasonCode,
uint32_t dwBufferSize,
const uint16_t* pStringBuffer,
void* pReserved);
]]
local wlanapi = ffi.load("wlanapi")
-- wlanapi.WlanReasonCodeToString(dwReasonCode, dwBufferSize, pStringBuffer, pReserved)
-- dwReasonCode : DWORD
-- dwBufferSize : DWORD
-- pStringBuffer : LPWSTR
-- pReserved : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wlanapi.dll');
const WlanReasonCodeToString = lib.func('__stdcall', 'WlanReasonCodeToString', 'uint32_t', ['uint32_t', 'uint32_t', 'str16', 'void *']);
// WlanReasonCodeToString(dwReasonCode, dwBufferSize, pStringBuffer, pReserved)
// dwReasonCode : DWORD -> 'uint32_t'
// dwBufferSize : DWORD -> 'uint32_t'
// pStringBuffer : LPWSTR -> 'str16'
// pReserved : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wlanapi.dll", {
WlanReasonCodeToString: { parameters: ["u32", "u32", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.WlanReasonCodeToString(dwReasonCode, dwBufferSize, pStringBuffer, pReserved)
// dwReasonCode : DWORD -> "u32"
// dwBufferSize : DWORD -> "u32"
// pStringBuffer : LPWSTR -> "buffer"
// pReserved : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t WlanReasonCodeToString(
uint32_t dwReasonCode,
uint32_t dwBufferSize,
const uint16_t* pStringBuffer,
void* pReserved);
C, "wlanapi.dll");
// $ffi->WlanReasonCodeToString(dwReasonCode, dwBufferSize, pStringBuffer, pReserved);
// dwReasonCode : DWORD
// dwBufferSize : DWORD
// pStringBuffer : LPWSTR
// 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 WlanReasonCodeToString(
int dwReasonCode, // DWORD
int dwBufferSize, // DWORD
WString pStringBuffer, // LPWSTR
Pointer pReserved // void* optional
);
}@[Link("wlanapi")]
lib Libwlanapi
fun WlanReasonCodeToString = WlanReasonCodeToString(
dwReasonCode : UInt32, # DWORD
dwBufferSize : UInt32, # DWORD
pStringBuffer : UInt16*, # LPWSTR
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 WlanReasonCodeToStringNative = Uint32 Function(Uint32, Uint32, Pointer<Utf16>, Pointer<Void>);
typedef WlanReasonCodeToStringDart = int Function(int, int, Pointer<Utf16>, Pointer<Void>);
final WlanReasonCodeToString = DynamicLibrary.open('wlanapi.dll')
.lookupFunction<WlanReasonCodeToStringNative, WlanReasonCodeToStringDart>('WlanReasonCodeToString');
// dwReasonCode : DWORD -> Uint32
// dwBufferSize : DWORD -> Uint32
// pStringBuffer : LPWSTR -> Pointer<Utf16>
// pReserved : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WlanReasonCodeToString(
dwReasonCode: DWORD; // DWORD
dwBufferSize: DWORD; // DWORD
pStringBuffer: PWideChar; // LPWSTR
pReserved: Pointer // void* optional
): DWORD; stdcall;
external 'wlanapi.dll' name 'WlanReasonCodeToString';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WlanReasonCodeToString"
c_WlanReasonCodeToString :: Word32 -> Word32 -> CWString -> Ptr () -> IO Word32
-- dwReasonCode : DWORD -> Word32
-- dwBufferSize : DWORD -> Word32
-- pStringBuffer : LPWSTR -> CWString
-- pReserved : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wlanreasoncodetostring =
foreign "WlanReasonCodeToString"
(uint32_t @-> uint32_t @-> (ptr uint16_t) @-> (ptr void) @-> returning uint32_t)
(* dwReasonCode : DWORD -> uint32_t *)
(* dwBufferSize : DWORD -> uint32_t *)
(* pStringBuffer : LPWSTR -> (ptr uint16_t) *)
(* 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 ("WlanReasonCodeToString" wlan-reason-code-to-string :convention :stdcall) :uint32
(dw-reason-code :uint32) ; DWORD
(dw-buffer-size :uint32) ; DWORD
(p-string-buffer (:string :encoding :utf-16le)) ; LPWSTR
(p-reserved :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WlanReasonCodeToString = Win32::API::More->new('wlanapi',
'DWORD WlanReasonCodeToString(DWORD dwReasonCode, DWORD dwBufferSize, LPCWSTR pStringBuffer, LPVOID pReserved)');
# my $ret = $WlanReasonCodeToString->Call($dwReasonCode, $dwBufferSize, $pStringBuffer, $pReserved);
# dwReasonCode : DWORD -> DWORD
# dwBufferSize : DWORD -> DWORD
# pStringBuffer : LPWSTR -> LPCWSTR
# pReserved : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。