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

BluetoothSdpGetAttributeValue

関数
SDPレコードから指定属性IDの値を取得する。
DLLBluetoothApis.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD BluetoothSdpGetAttributeValue(
    BYTE* pRecordStream,
    DWORD cbRecordLength,
    WORD usAttributeId,
    SDP_ELEMENT_DATA* pAttributeData
);

パラメーター

名前方向
pRecordStreamBYTE*in
cbRecordLengthDWORDin
usAttributeIdWORDin
pAttributeDataSDP_ELEMENT_DATA*out

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // DWORD
function 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)。