Win32 API 日本語リファレンス
ホームDevices.Bluetooth › BluetoothSdpEnumAttributes

BluetoothSdpEnumAttributes

関数
SDPストリーム内の全属性をコールバックで列挙する。
DLLBluetoothApis.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL BluetoothSdpEnumAttributes(
    BYTE* pSDPStream,
    DWORD cbStreamSize,
    PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK pfnCallback,
    void* pvParam
);

パラメーター

名前方向説明
pSDPStreamBYTE*in属性を列挙する対象SDPレコードのバイトストリームへのポインタ。
cbStreamSizeDWORDinpSDPStreamのバイト長。
pfnCallbackPFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACKin各属性ごとに呼ばれる列挙コールバック関数へのポインタ。FALSE返却で列挙中止。
pvParamvoid*inコールバックに渡される任意のパラメータポインタ。NULL可。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL BluetoothSdpEnumAttributes(
    BYTE* pSDPStream,
    DWORD cbStreamSize,
    PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK pfnCallback,
    void* pvParam
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("BluetoothApis.dll", SetLastError = true, ExactSpelling = true)]
static extern bool BluetoothSdpEnumAttributes(
    IntPtr pSDPStream,   // BYTE*
    uint cbStreamSize,   // DWORD
    IntPtr pfnCallback,   // PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
    IntPtr pvParam   // void*
);
<DllImport("BluetoothApis.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function BluetoothSdpEnumAttributes(
    pSDPStream As IntPtr,   ' BYTE*
    cbStreamSize As UInteger,   ' DWORD
    pfnCallback As IntPtr,   ' PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
    pvParam As IntPtr   ' void*
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' pSDPStream : BYTE*
' cbStreamSize : DWORD
' pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
' pvParam : void*
Declare PtrSafe Function BluetoothSdpEnumAttributes Lib "bluetoothapis" ( _
    ByVal pSDPStream As LongPtr, _
    ByVal cbStreamSize As Long, _
    ByVal pfnCallback As LongPtr, _
    ByVal pvParam As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BluetoothSdpEnumAttributes = ctypes.windll.bluetoothapis.BluetoothSdpEnumAttributes
BluetoothSdpEnumAttributes.restype = wintypes.BOOL
BluetoothSdpEnumAttributes.argtypes = [
    ctypes.POINTER(ctypes.c_ubyte),  # pSDPStream : BYTE*
    wintypes.DWORD,  # cbStreamSize : DWORD
    ctypes.c_void_p,  # pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
    ctypes.POINTER(None),  # pvParam : void*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothSdpEnumAttributes = Fiddle::Function.new(
  lib['BluetoothSdpEnumAttributes'],
  [
    Fiddle::TYPE_VOIDP,  # pSDPStream : BYTE*
    -Fiddle::TYPE_INT,  # cbStreamSize : DWORD
    Fiddle::TYPE_VOIDP,  # pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
    Fiddle::TYPE_VOIDP,  # pvParam : void*
  ],
  Fiddle::TYPE_INT)
#[link(name = "bluetoothapis")]
extern "system" {
    fn BluetoothSdpEnumAttributes(
        pSDPStream: *mut u8,  // BYTE*
        cbStreamSize: u32,  // DWORD
        pfnCallback: *const core::ffi::c_void,  // PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
        pvParam: *mut ()  // void*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("BluetoothApis.dll", SetLastError = true)]
public static extern bool BluetoothSdpEnumAttributes(IntPtr pSDPStream, uint cbStreamSize, IntPtr pfnCallback, IntPtr pvParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothSdpEnumAttributes' -Namespace Win32 -PassThru
# $api::BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam)
#uselib "BluetoothApis.dll"
#func global BluetoothSdpEnumAttributes "BluetoothSdpEnumAttributes" sptr, sptr, sptr, sptr
; BluetoothSdpEnumAttributes varptr(pSDPStream), cbStreamSize, pfnCallback, pvParam   ; 戻り値は stat
; pSDPStream : BYTE* -> "sptr"
; cbStreamSize : DWORD -> "sptr"
; pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> "sptr"
; pvParam : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "BluetoothApis.dll"
#cfunc global BluetoothSdpEnumAttributes "BluetoothSdpEnumAttributes" var, int, sptr, sptr
; res = BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam)
; pSDPStream : BYTE* -> "var"
; cbStreamSize : DWORD -> "int"
; pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> "sptr"
; pvParam : void* -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL BluetoothSdpEnumAttributes(BYTE* pSDPStream, DWORD cbStreamSize, PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK pfnCallback, void* pvParam)
#uselib "BluetoothApis.dll"
#cfunc global BluetoothSdpEnumAttributes "BluetoothSdpEnumAttributes" var, int, intptr, intptr
; res = BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam)
; pSDPStream : BYTE* -> "var"
; cbStreamSize : DWORD -> "int"
; pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> "intptr"
; pvParam : void* -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothSdpEnumAttributes = bluetoothapis.NewProc("BluetoothSdpEnumAttributes")
)

// pSDPStream (BYTE*), cbStreamSize (DWORD), pfnCallback (PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK), pvParam (void*)
r1, _, err := procBluetoothSdpEnumAttributes.Call(
	uintptr(pSDPStream),
	uintptr(cbStreamSize),
	uintptr(pfnCallback),
	uintptr(pvParam),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function BluetoothSdpEnumAttributes(
  pSDPStream: Pointer;   // BYTE*
  cbStreamSize: DWORD;   // DWORD
  pfnCallback: Pointer;   // PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
  pvParam: Pointer   // void*
): BOOL; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothSdpEnumAttributes';
result := DllCall("BluetoothApis\BluetoothSdpEnumAttributes"
    , "Ptr", pSDPStream   ; BYTE*
    , "UInt", cbStreamSize   ; DWORD
    , "Ptr", pfnCallback   ; PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
    , "Ptr", pvParam   ; void*
    , "Int")   ; return: BOOL
●BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam) = DLL("BluetoothApis.dll", "bool BluetoothSdpEnumAttributes(void*, dword, void*, void*)")
# 呼び出し: BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam)
# pSDPStream : BYTE* -> "void*"
# cbStreamSize : DWORD -> "dword"
# pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> "void*"
# pvParam : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "bluetoothapis" fn BluetoothSdpEnumAttributes(
    pSDPStream: [*c]u8, // BYTE*
    cbStreamSize: u32, // DWORD
    pfnCallback: ?*anyopaque, // PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
    pvParam: ?*anyopaque // void*
) callconv(std.os.windows.WINAPI) i32;
proc BluetoothSdpEnumAttributes(
    pSDPStream: ptr uint8,  # BYTE*
    cbStreamSize: uint32,  # DWORD
    pfnCallback: pointer,  # PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
    pvParam: pointer  # void*
): int32 {.importc: "BluetoothSdpEnumAttributes", stdcall, dynlib: "BluetoothApis.dll".}
pragma(lib, "bluetoothapis");
extern(Windows)
int BluetoothSdpEnumAttributes(
    ubyte* pSDPStream,   // BYTE*
    uint cbStreamSize,   // DWORD
    void* pfnCallback,   // PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
    void* pvParam   // void*
);
ccall((:BluetoothSdpEnumAttributes, "BluetoothApis.dll"), stdcall, Int32,
      (Ptr{UInt8}, UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
      pSDPStream, cbStreamSize, pfnCallback, pvParam)
# pSDPStream : BYTE* -> Ptr{UInt8}
# cbStreamSize : DWORD -> UInt32
# pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> Ptr{Cvoid}
# pvParam : void* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t BluetoothSdpEnumAttributes(
    uint8_t* pSDPStream,
    uint32_t cbStreamSize,
    void* pfnCallback,
    void* pvParam);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam)
-- pSDPStream : BYTE*
-- cbStreamSize : DWORD
-- pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
-- pvParam : void*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothSdpEnumAttributes = lib.func('__stdcall', 'BluetoothSdpEnumAttributes', 'int32_t', ['uint8_t *', 'uint32_t', 'void *', 'void *']);
// BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam)
// pSDPStream : BYTE* -> 'uint8_t *'
// cbStreamSize : DWORD -> 'uint32_t'
// pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> 'void *'
// pvParam : void* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("BluetoothApis.dll", {
  BluetoothSdpEnumAttributes: { parameters: ["pointer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam)
// pSDPStream : BYTE* -> "pointer"
// cbStreamSize : DWORD -> "u32"
// pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> "pointer"
// pvParam : void* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t BluetoothSdpEnumAttributes(
    uint8_t* pSDPStream,
    uint32_t cbStreamSize,
    void* pfnCallback,
    void* pvParam);
C, "BluetoothApis.dll");
// $ffi->BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam);
// pSDPStream : BYTE*
// cbStreamSize : DWORD
// pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
// pvParam : void*
// 構造体/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);
    boolean BluetoothSdpEnumAttributes(
        byte[] pSDPStream,   // BYTE*
        int cbStreamSize,   // DWORD
        Callback pfnCallback,   // PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
        Pointer pvParam   // void*
    );
}
@[Link("bluetoothapis")]
lib LibBluetoothApis
  fun BluetoothSdpEnumAttributes = BluetoothSdpEnumAttributes(
    pSDPStream : UInt8*,   # BYTE*
    cbStreamSize : UInt32,   # DWORD
    pfnCallback : Void*,   # PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
    pvParam : Void*   # void*
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef BluetoothSdpEnumAttributesNative = Int32 Function(Pointer<Uint8>, Uint32, Pointer<Void>, Pointer<Void>);
typedef BluetoothSdpEnumAttributesDart = int Function(Pointer<Uint8>, int, Pointer<Void>, Pointer<Void>);
final BluetoothSdpEnumAttributes = DynamicLibrary.open('BluetoothApis.dll')
    .lookupFunction<BluetoothSdpEnumAttributesNative, BluetoothSdpEnumAttributesDart>('BluetoothSdpEnumAttributes');
// pSDPStream : BYTE* -> Pointer<Uint8>
// cbStreamSize : DWORD -> Uint32
// pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> Pointer<Void>
// pvParam : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function BluetoothSdpEnumAttributes(
  pSDPStream: Pointer;   // BYTE*
  cbStreamSize: DWORD;   // DWORD
  pfnCallback: Pointer;   // PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
  pvParam: Pointer   // void*
): BOOL; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothSdpEnumAttributes';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "BluetoothSdpEnumAttributes"
  c_BluetoothSdpEnumAttributes :: Ptr Word8 -> Word32 -> Ptr () -> Ptr () -> IO CInt
-- pSDPStream : BYTE* -> Ptr Word8
-- cbStreamSize : DWORD -> Word32
-- pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> Ptr ()
-- pvParam : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let bluetoothsdpenumattributes =
  foreign "BluetoothSdpEnumAttributes"
    ((ptr uint8_t) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pSDPStream : BYTE* -> (ptr uint8_t) *)
(* cbStreamSize : DWORD -> uint32_t *)
(* pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> (ptr void) *)
(* pvParam : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library bluetoothapis (t "BluetoothApis.dll"))
(cffi:use-foreign-library bluetoothapis)

(cffi:defcfun ("BluetoothSdpEnumAttributes" bluetooth-sdp-enum-attributes :convention :stdcall) :int32
  (p-sdpstream :pointer)   ; BYTE*
  (cb-stream-size :uint32)   ; DWORD
  (pfn-callback :pointer)   ; PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK
  (pv-param :pointer))   ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $BluetoothSdpEnumAttributes = Win32::API::More->new('BluetoothApis',
    'BOOL BluetoothSdpEnumAttributes(LPVOID pSDPStream, DWORD cbStreamSize, LPVOID pfnCallback, LPVOID pvParam)');
# my $ret = $BluetoothSdpEnumAttributes->Call($pSDPStream, $cbStreamSize, $pfnCallback, $pvParam);
# pSDPStream : BYTE* -> LPVOID
# cbStreamSize : DWORD -> DWORD
# pfnCallback : PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK -> LPVOID
# pvParam : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型