ホーム › Devices.Bluetooth › BluetoothSdpGetAttributeValue
BluetoothSdpGetAttributeValue
関数SDPレコードから指定属性IDの値を取得する。
シグネチャ
// BluetoothApis.dll
#include <windows.h>
DWORD BluetoothSdpGetAttributeValue(
BYTE* pRecordStream,
DWORD cbRecordLength,
WORD usAttributeId,
SDP_ELEMENT_DATA* pAttributeData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pRecordStream | BYTE* | in | 解析対象のSDPレコードを含むバイトストリームへのポインタ。 |
| cbRecordLength | DWORD | in | pRecordStreamのバイト長。 |
| usAttributeId | WORD | in | 取得する属性を識別する属性IDの16ビット値。 |
| pAttributeData | SDP_ELEMENT_DATA* | out | 指定属性の値を受け取るSDPエレメントデータ構造体ポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// BluetoothApis.dll
#include <windows.h>
DWORD BluetoothSdpGetAttributeValue(
BYTE* pRecordStream,
DWORD cbRecordLength,
WORD usAttributeId,
SDP_ELEMENT_DATA* pAttributeData
);[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern uint BluetoothSdpGetAttributeValue(
IntPtr pRecordStream, // BYTE*
uint cbRecordLength, // DWORD
ushort usAttributeId, // WORD
IntPtr pAttributeData // SDP_ELEMENT_DATA* out
);<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothSdpGetAttributeValue(
pRecordStream As IntPtr, ' BYTE*
cbRecordLength As UInteger, ' DWORD
usAttributeId As UShort, ' WORD
pAttributeData As IntPtr ' SDP_ELEMENT_DATA* out
) As UInteger
End Function' pRecordStream : BYTE*
' cbRecordLength : DWORD
' usAttributeId : WORD
' pAttributeData : SDP_ELEMENT_DATA* out
Declare PtrSafe Function BluetoothSdpGetAttributeValue Lib "bluetoothapis" ( _
ByVal pRecordStream As LongPtr, _
ByVal cbRecordLength As Long, _
ByVal usAttributeId As Integer, _
ByVal pAttributeData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BluetoothSdpGetAttributeValue = ctypes.windll.bluetoothapis.BluetoothSdpGetAttributeValue
BluetoothSdpGetAttributeValue.restype = wintypes.DWORD
BluetoothSdpGetAttributeValue.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # pRecordStream : BYTE*
wintypes.DWORD, # cbRecordLength : DWORD
ctypes.c_ushort, # usAttributeId : WORD
ctypes.c_void_p, # pAttributeData : SDP_ELEMENT_DATA* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothSdpGetAttributeValue = Fiddle::Function.new(
lib['BluetoothSdpGetAttributeValue'],
[
Fiddle::TYPE_VOIDP, # pRecordStream : BYTE*
-Fiddle::TYPE_INT, # cbRecordLength : DWORD
-Fiddle::TYPE_SHORT, # usAttributeId : WORD
Fiddle::TYPE_VOIDP, # pAttributeData : SDP_ELEMENT_DATA* out
],
-Fiddle::TYPE_INT)#[link(name = "bluetoothapis")]
extern "system" {
fn BluetoothSdpGetAttributeValue(
pRecordStream: *mut u8, // BYTE*
cbRecordLength: u32, // DWORD
usAttributeId: u16, // WORD
pAttributeData: *mut SDP_ELEMENT_DATA // SDP_ELEMENT_DATA* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("BluetoothApis.dll")]
public static extern uint BluetoothSdpGetAttributeValue(IntPtr pRecordStream, uint cbRecordLength, ushort usAttributeId, IntPtr pAttributeData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothSdpGetAttributeValue' -Namespace Win32 -PassThru
# $api::BluetoothSdpGetAttributeValue(pRecordStream, cbRecordLength, usAttributeId, pAttributeData)#uselib "BluetoothApis.dll"
#func global BluetoothSdpGetAttributeValue "BluetoothSdpGetAttributeValue" sptr, sptr, sptr, sptr
; BluetoothSdpGetAttributeValue varptr(pRecordStream), cbRecordLength, usAttributeId, varptr(pAttributeData) ; 戻り値は stat
; pRecordStream : BYTE* -> "sptr"
; cbRecordLength : DWORD -> "sptr"
; usAttributeId : WORD -> "sptr"
; pAttributeData : SDP_ELEMENT_DATA* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "BluetoothApis.dll" #cfunc global BluetoothSdpGetAttributeValue "BluetoothSdpGetAttributeValue" var, int, int, var ; res = BluetoothSdpGetAttributeValue(pRecordStream, cbRecordLength, usAttributeId, pAttributeData) ; pRecordStream : BYTE* -> "var" ; cbRecordLength : DWORD -> "int" ; usAttributeId : WORD -> "int" ; pAttributeData : SDP_ELEMENT_DATA* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "BluetoothApis.dll" #cfunc global BluetoothSdpGetAttributeValue "BluetoothSdpGetAttributeValue" sptr, int, int, sptr ; res = BluetoothSdpGetAttributeValue(varptr(pRecordStream), cbRecordLength, usAttributeId, varptr(pAttributeData)) ; pRecordStream : BYTE* -> "sptr" ; cbRecordLength : DWORD -> "int" ; usAttributeId : WORD -> "int" ; pAttributeData : SDP_ELEMENT_DATA* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD BluetoothSdpGetAttributeValue(BYTE* pRecordStream, DWORD cbRecordLength, WORD usAttributeId, SDP_ELEMENT_DATA* pAttributeData) #uselib "BluetoothApis.dll" #cfunc global BluetoothSdpGetAttributeValue "BluetoothSdpGetAttributeValue" var, int, int, var ; res = BluetoothSdpGetAttributeValue(pRecordStream, cbRecordLength, usAttributeId, pAttributeData) ; pRecordStream : BYTE* -> "var" ; cbRecordLength : DWORD -> "int" ; usAttributeId : WORD -> "int" ; pAttributeData : SDP_ELEMENT_DATA* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD BluetoothSdpGetAttributeValue(BYTE* pRecordStream, DWORD cbRecordLength, WORD usAttributeId, SDP_ELEMENT_DATA* pAttributeData) #uselib "BluetoothApis.dll" #cfunc global BluetoothSdpGetAttributeValue "BluetoothSdpGetAttributeValue" intptr, int, int, intptr ; res = BluetoothSdpGetAttributeValue(varptr(pRecordStream), cbRecordLength, usAttributeId, varptr(pAttributeData)) ; pRecordStream : BYTE* -> "intptr" ; cbRecordLength : DWORD -> "int" ; usAttributeId : WORD -> "int" ; pAttributeData : SDP_ELEMENT_DATA* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
procBluetoothSdpGetAttributeValue = bluetoothapis.NewProc("BluetoothSdpGetAttributeValue")
)
// pRecordStream (BYTE*), cbRecordLength (DWORD), usAttributeId (WORD), pAttributeData (SDP_ELEMENT_DATA* out)
r1, _, err := procBluetoothSdpGetAttributeValue.Call(
uintptr(pRecordStream),
uintptr(cbRecordLength),
uintptr(usAttributeId),
uintptr(pAttributeData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction BluetoothSdpGetAttributeValue(
pRecordStream: Pointer; // BYTE*
cbRecordLength: DWORD; // DWORD
usAttributeId: Word; // WORD
pAttributeData: Pointer // SDP_ELEMENT_DATA* out
): DWORD; stdcall;
external 'BluetoothApis.dll' name 'BluetoothSdpGetAttributeValue';result := DllCall("BluetoothApis\BluetoothSdpGetAttributeValue"
, "Ptr", pRecordStream ; BYTE*
, "UInt", cbRecordLength ; DWORD
, "UShort", usAttributeId ; WORD
, "Ptr", pAttributeData ; SDP_ELEMENT_DATA* out
, "UInt") ; return: DWORD●BluetoothSdpGetAttributeValue(pRecordStream, cbRecordLength, usAttributeId, pAttributeData) = DLL("BluetoothApis.dll", "dword BluetoothSdpGetAttributeValue(void*, dword, int, void*)")
# 呼び出し: BluetoothSdpGetAttributeValue(pRecordStream, cbRecordLength, usAttributeId, pAttributeData)
# pRecordStream : BYTE* -> "void*"
# cbRecordLength : DWORD -> "dword"
# usAttributeId : WORD -> "int"
# pAttributeData : SDP_ELEMENT_DATA* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bluetoothapis" fn BluetoothSdpGetAttributeValue(
pRecordStream: [*c]u8, // BYTE*
cbRecordLength: u32, // DWORD
usAttributeId: u16, // WORD
pAttributeData: [*c]SDP_ELEMENT_DATA // SDP_ELEMENT_DATA* out
) callconv(std.os.windows.WINAPI) u32;proc BluetoothSdpGetAttributeValue(
pRecordStream: ptr uint8, # BYTE*
cbRecordLength: uint32, # DWORD
usAttributeId: uint16, # WORD
pAttributeData: ptr SDP_ELEMENT_DATA # SDP_ELEMENT_DATA* out
): uint32 {.importc: "BluetoothSdpGetAttributeValue", stdcall, dynlib: "BluetoothApis.dll".}pragma(lib, "bluetoothapis");
extern(Windows)
uint BluetoothSdpGetAttributeValue(
ubyte* pRecordStream, // BYTE*
uint cbRecordLength, // DWORD
ushort usAttributeId, // WORD
SDP_ELEMENT_DATA* pAttributeData // SDP_ELEMENT_DATA* out
);ccall((:BluetoothSdpGetAttributeValue, "BluetoothApis.dll"), stdcall, UInt32,
(Ptr{UInt8}, UInt32, UInt16, Ptr{SDP_ELEMENT_DATA}),
pRecordStream, cbRecordLength, usAttributeId, pAttributeData)
# pRecordStream : BYTE* -> Ptr{UInt8}
# cbRecordLength : DWORD -> UInt32
# usAttributeId : WORD -> UInt16
# pAttributeData : SDP_ELEMENT_DATA* out -> Ptr{SDP_ELEMENT_DATA}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t BluetoothSdpGetAttributeValue(
uint8_t* pRecordStream,
uint32_t cbRecordLength,
uint16_t usAttributeId,
void* pAttributeData);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothSdpGetAttributeValue(pRecordStream, cbRecordLength, usAttributeId, pAttributeData)
-- pRecordStream : BYTE*
-- cbRecordLength : DWORD
-- usAttributeId : WORD
-- pAttributeData : SDP_ELEMENT_DATA* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothSdpGetAttributeValue = lib.func('__stdcall', 'BluetoothSdpGetAttributeValue', 'uint32_t', ['uint8_t *', 'uint32_t', 'uint16_t', 'void *']);
// BluetoothSdpGetAttributeValue(pRecordStream, cbRecordLength, usAttributeId, pAttributeData)
// pRecordStream : BYTE* -> 'uint8_t *'
// cbRecordLength : DWORD -> 'uint32_t'
// usAttributeId : WORD -> 'uint16_t'
// pAttributeData : SDP_ELEMENT_DATA* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("BluetoothApis.dll", {
BluetoothSdpGetAttributeValue: { parameters: ["pointer", "u32", "u16", "pointer"], result: "u32" },
});
// lib.symbols.BluetoothSdpGetAttributeValue(pRecordStream, cbRecordLength, usAttributeId, pAttributeData)
// pRecordStream : BYTE* -> "pointer"
// cbRecordLength : DWORD -> "u32"
// usAttributeId : WORD -> "u16"
// pAttributeData : SDP_ELEMENT_DATA* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t BluetoothSdpGetAttributeValue(
uint8_t* pRecordStream,
uint32_t cbRecordLength,
uint16_t usAttributeId,
void* pAttributeData);
C, "BluetoothApis.dll");
// $ffi->BluetoothSdpGetAttributeValue(pRecordStream, cbRecordLength, usAttributeId, pAttributeData);
// pRecordStream : BYTE*
// cbRecordLength : DWORD
// usAttributeId : WORD
// pAttributeData : SDP_ELEMENT_DATA* 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);
int BluetoothSdpGetAttributeValue(
byte[] pRecordStream, // BYTE*
int cbRecordLength, // DWORD
short usAttributeId, // WORD
Pointer pAttributeData // SDP_ELEMENT_DATA* out
);
}@[Link("bluetoothapis")]
lib LibBluetoothApis
fun BluetoothSdpGetAttributeValue = BluetoothSdpGetAttributeValue(
pRecordStream : UInt8*, # BYTE*
cbRecordLength : UInt32, # DWORD
usAttributeId : UInt16, # WORD
pAttributeData : SDP_ELEMENT_DATA* # SDP_ELEMENT_DATA* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BluetoothSdpGetAttributeValueNative = Uint32 Function(Pointer<Uint8>, Uint32, Uint16, Pointer<Void>);
typedef BluetoothSdpGetAttributeValueDart = int Function(Pointer<Uint8>, int, int, Pointer<Void>);
final BluetoothSdpGetAttributeValue = DynamicLibrary.open('BluetoothApis.dll')
.lookupFunction<BluetoothSdpGetAttributeValueNative, BluetoothSdpGetAttributeValueDart>('BluetoothSdpGetAttributeValue');
// pRecordStream : BYTE* -> Pointer<Uint8>
// cbRecordLength : DWORD -> Uint32
// usAttributeId : WORD -> Uint16
// pAttributeData : SDP_ELEMENT_DATA* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BluetoothSdpGetAttributeValue(
pRecordStream: Pointer; // BYTE*
cbRecordLength: DWORD; // DWORD
usAttributeId: Word; // WORD
pAttributeData: Pointer // SDP_ELEMENT_DATA* out
): DWORD; stdcall;
external 'BluetoothApis.dll' name 'BluetoothSdpGetAttributeValue';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BluetoothSdpGetAttributeValue"
c_BluetoothSdpGetAttributeValue :: Ptr Word8 -> Word32 -> Word16 -> Ptr () -> IO Word32
-- pRecordStream : BYTE* -> Ptr Word8
-- cbRecordLength : DWORD -> Word32
-- usAttributeId : WORD -> Word16
-- pAttributeData : SDP_ELEMENT_DATA* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bluetoothsdpgetattributevalue =
foreign "BluetoothSdpGetAttributeValue"
((ptr uint8_t) @-> uint32_t @-> uint16_t @-> (ptr void) @-> returning uint32_t)
(* pRecordStream : BYTE* -> (ptr uint8_t) *)
(* cbRecordLength : DWORD -> uint32_t *)
(* usAttributeId : WORD -> uint16_t *)
(* pAttributeData : SDP_ELEMENT_DATA* 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 ("BluetoothSdpGetAttributeValue" bluetooth-sdp-get-attribute-value :convention :stdcall) :uint32
(p-record-stream :pointer) ; BYTE*
(cb-record-length :uint32) ; DWORD
(us-attribute-id :uint16) ; WORD
(p-attribute-data :pointer)) ; SDP_ELEMENT_DATA* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BluetoothSdpGetAttributeValue = Win32::API::More->new('BluetoothApis',
'DWORD BluetoothSdpGetAttributeValue(LPVOID pRecordStream, DWORD cbRecordLength, WORD usAttributeId, LPVOID pAttributeData)');
# my $ret = $BluetoothSdpGetAttributeValue->Call($pRecordStream, $cbRecordLength, $usAttributeId, $pAttributeData);
# pRecordStream : BYTE* -> LPVOID
# cbRecordLength : DWORD -> DWORD
# usAttributeId : WORD -> WORD
# pAttributeData : SDP_ELEMENT_DATA* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型