ホーム › Devices.Bluetooth › BluetoothFindFirstRadio
BluetoothFindFirstRadio
関数最初のBluetoothラジオを検索しハンドルを取得する。
シグネチャ
// BluetoothApis.dll
#include <windows.h>
HBLUETOOTH_RADIO_FIND BluetoothFindFirstRadio(
const BLUETOOTH_FIND_RADIO_PARAMS* pbtfrp,
HANDLE* phRadio
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pbtfrp | BLUETOOTH_FIND_RADIO_PARAMS* | in | ラジオ検索パラメータ構造体へのポインタ。dwSizeの設定が必要。 |
| phRadio | HANDLE* | out | 最初に見つかったBluetoothラジオのハンドルを受け取る出力ポインタ。 |
戻り値の型: HBLUETOOTH_RADIO_FIND
各言語での呼び出し定義
// BluetoothApis.dll
#include <windows.h>
HBLUETOOTH_RADIO_FIND BluetoothFindFirstRadio(
const BLUETOOTH_FIND_RADIO_PARAMS* pbtfrp,
HANDLE* phRadio
);[DllImport("BluetoothApis.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr BluetoothFindFirstRadio(
IntPtr pbtfrp, // BLUETOOTH_FIND_RADIO_PARAMS*
IntPtr phRadio // HANDLE* out
);<DllImport("BluetoothApis.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function BluetoothFindFirstRadio(
pbtfrp As IntPtr, ' BLUETOOTH_FIND_RADIO_PARAMS*
phRadio As IntPtr ' HANDLE* out
) As IntPtr
End Function' pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS*
' phRadio : HANDLE* out
Declare PtrSafe Function BluetoothFindFirstRadio Lib "bluetoothapis" ( _
ByVal pbtfrp As LongPtr, _
ByVal phRadio As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BluetoothFindFirstRadio = ctypes.windll.bluetoothapis.BluetoothFindFirstRadio
BluetoothFindFirstRadio.restype = ctypes.c_void_p
BluetoothFindFirstRadio.argtypes = [
ctypes.c_void_p, # pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS*
ctypes.c_void_p, # phRadio : HANDLE* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothFindFirstRadio = Fiddle::Function.new(
lib['BluetoothFindFirstRadio'],
[
Fiddle::TYPE_VOIDP, # pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS*
Fiddle::TYPE_VOIDP, # phRadio : HANDLE* out
],
Fiddle::TYPE_VOIDP)#[link(name = "bluetoothapis")]
extern "system" {
fn BluetoothFindFirstRadio(
pbtfrp: *const BLUETOOTH_FIND_RADIO_PARAMS, // BLUETOOTH_FIND_RADIO_PARAMS*
phRadio: *mut *mut core::ffi::c_void // HANDLE* out
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("BluetoothApis.dll", SetLastError = true)]
public static extern IntPtr BluetoothFindFirstRadio(IntPtr pbtfrp, IntPtr phRadio);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothFindFirstRadio' -Namespace Win32 -PassThru
# $api::BluetoothFindFirstRadio(pbtfrp, phRadio)#uselib "BluetoothApis.dll"
#func global BluetoothFindFirstRadio "BluetoothFindFirstRadio" sptr, sptr
; BluetoothFindFirstRadio varptr(pbtfrp), phRadio ; 戻り値は stat
; pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> "sptr"
; phRadio : HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "BluetoothApis.dll" #cfunc global BluetoothFindFirstRadio "BluetoothFindFirstRadio" var, sptr ; res = BluetoothFindFirstRadio(pbtfrp, phRadio) ; pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> "var" ; phRadio : HANDLE* out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "BluetoothApis.dll" #cfunc global BluetoothFindFirstRadio "BluetoothFindFirstRadio" sptr, sptr ; res = BluetoothFindFirstRadio(varptr(pbtfrp), phRadio) ; pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> "sptr" ; phRadio : HANDLE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HBLUETOOTH_RADIO_FIND BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS* pbtfrp, HANDLE* phRadio) #uselib "BluetoothApis.dll" #cfunc global BluetoothFindFirstRadio "BluetoothFindFirstRadio" var, intptr ; res = BluetoothFindFirstRadio(pbtfrp, phRadio) ; pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> "var" ; phRadio : HANDLE* out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HBLUETOOTH_RADIO_FIND BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS* pbtfrp, HANDLE* phRadio) #uselib "BluetoothApis.dll" #cfunc global BluetoothFindFirstRadio "BluetoothFindFirstRadio" intptr, intptr ; res = BluetoothFindFirstRadio(varptr(pbtfrp), phRadio) ; pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> "intptr" ; phRadio : HANDLE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
procBluetoothFindFirstRadio = bluetoothapis.NewProc("BluetoothFindFirstRadio")
)
// pbtfrp (BLUETOOTH_FIND_RADIO_PARAMS*), phRadio (HANDLE* out)
r1, _, err := procBluetoothFindFirstRadio.Call(
uintptr(pbtfrp),
uintptr(phRadio),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HBLUETOOTH_RADIO_FINDfunction BluetoothFindFirstRadio(
pbtfrp: Pointer; // BLUETOOTH_FIND_RADIO_PARAMS*
phRadio: Pointer // HANDLE* out
): THandle; stdcall;
external 'BluetoothApis.dll' name 'BluetoothFindFirstRadio';result := DllCall("BluetoothApis\BluetoothFindFirstRadio"
, "Ptr", pbtfrp ; BLUETOOTH_FIND_RADIO_PARAMS*
, "Ptr", phRadio ; HANDLE* out
, "Ptr") ; return: HBLUETOOTH_RADIO_FIND●BluetoothFindFirstRadio(pbtfrp, phRadio) = DLL("BluetoothApis.dll", "void* BluetoothFindFirstRadio(void*, void*)")
# 呼び出し: BluetoothFindFirstRadio(pbtfrp, phRadio)
# pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> "void*"
# phRadio : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bluetoothapis" fn BluetoothFindFirstRadio(
pbtfrp: [*c]BLUETOOTH_FIND_RADIO_PARAMS, // BLUETOOTH_FIND_RADIO_PARAMS*
phRadio: ?*anyopaque // HANDLE* out
) callconv(std.os.windows.WINAPI) ?*anyopaque;proc BluetoothFindFirstRadio(
pbtfrp: ptr BLUETOOTH_FIND_RADIO_PARAMS, # BLUETOOTH_FIND_RADIO_PARAMS*
phRadio: pointer # HANDLE* out
): pointer {.importc: "BluetoothFindFirstRadio", stdcall, dynlib: "BluetoothApis.dll".}pragma(lib, "bluetoothapis");
extern(Windows)
void* BluetoothFindFirstRadio(
BLUETOOTH_FIND_RADIO_PARAMS* pbtfrp, // BLUETOOTH_FIND_RADIO_PARAMS*
void* phRadio // HANDLE* out
);ccall((:BluetoothFindFirstRadio, "BluetoothApis.dll"), stdcall, Ptr{Cvoid},
(Ptr{BLUETOOTH_FIND_RADIO_PARAMS}, Ptr{Cvoid}),
pbtfrp, phRadio)
# pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> Ptr{BLUETOOTH_FIND_RADIO_PARAMS}
# phRadio : HANDLE* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* BluetoothFindFirstRadio(
void* pbtfrp,
void* phRadio);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothFindFirstRadio(pbtfrp, phRadio)
-- pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS*
-- phRadio : HANDLE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothFindFirstRadio = lib.func('__stdcall', 'BluetoothFindFirstRadio', 'void *', ['void *', 'void *']);
// BluetoothFindFirstRadio(pbtfrp, phRadio)
// pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> 'void *'
// phRadio : HANDLE* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("BluetoothApis.dll", {
BluetoothFindFirstRadio: { parameters: ["pointer", "pointer"], result: "pointer" },
});
// lib.symbols.BluetoothFindFirstRadio(pbtfrp, phRadio)
// pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> "pointer"
// phRadio : HANDLE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* BluetoothFindFirstRadio(
void* pbtfrp,
void* phRadio);
C, "BluetoothApis.dll");
// $ffi->BluetoothFindFirstRadio(pbtfrp, phRadio);
// pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS*
// phRadio : HANDLE* out
// 構造体/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 Bluetoothapis extends StdCallLibrary {
Bluetoothapis INSTANCE = Native.load("bluetoothapis", Bluetoothapis.class);
Pointer BluetoothFindFirstRadio(
Pointer pbtfrp, // BLUETOOTH_FIND_RADIO_PARAMS*
Pointer phRadio // HANDLE* out
);
}@[Link("bluetoothapis")]
lib LibBluetoothApis
fun BluetoothFindFirstRadio = BluetoothFindFirstRadio(
pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS*, # BLUETOOTH_FIND_RADIO_PARAMS*
phRadio : Void* # HANDLE* out
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BluetoothFindFirstRadioNative = Pointer<Void> Function(Pointer<Void>, Pointer<Void>);
typedef BluetoothFindFirstRadioDart = Pointer<Void> Function(Pointer<Void>, Pointer<Void>);
final BluetoothFindFirstRadio = DynamicLibrary.open('BluetoothApis.dll')
.lookupFunction<BluetoothFindFirstRadioNative, BluetoothFindFirstRadioDart>('BluetoothFindFirstRadio');
// pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> Pointer<Void>
// phRadio : HANDLE* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BluetoothFindFirstRadio(
pbtfrp: Pointer; // BLUETOOTH_FIND_RADIO_PARAMS*
phRadio: Pointer // HANDLE* out
): THandle; stdcall;
external 'BluetoothApis.dll' name 'BluetoothFindFirstRadio';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BluetoothFindFirstRadio"
c_BluetoothFindFirstRadio :: Ptr () -> Ptr () -> IO (Ptr ())
-- pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> Ptr ()
-- phRadio : HANDLE* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bluetoothfindfirstradio =
foreign "BluetoothFindFirstRadio"
((ptr void) @-> (ptr void) @-> returning (ptr void))
(* pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> (ptr void) *)
(* phRadio : HANDLE* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library bluetoothapis (t "BluetoothApis.dll"))
(cffi:use-foreign-library bluetoothapis)
(cffi:defcfun ("BluetoothFindFirstRadio" bluetooth-find-first-radio :convention :stdcall) :pointer
(pbtfrp :pointer) ; BLUETOOTH_FIND_RADIO_PARAMS*
(ph-radio :pointer)) ; HANDLE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BluetoothFindFirstRadio = Win32::API::More->new('BluetoothApis',
'HANDLE BluetoothFindFirstRadio(LPVOID pbtfrp, HANDLE phRadio)');
# my $ret = $BluetoothFindFirstRadio->Call($pbtfrp, $phRadio);
# pbtfrp : BLUETOOTH_FIND_RADIO_PARAMS* -> LPVOID
# phRadio : HANDLE* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。