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

BluetoothSdpGetElementData

関数
SDPストリームから単一要素のデータを取得する。
DLLBluetoothApis.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD BluetoothSdpGetElementData(
    BYTE* pSdpStream,
    DWORD cbSdpStreamLength,
    SDP_ELEMENT_DATA* pData
);

パラメーター

名前方向説明
pSdpStreamBYTE*in解析対象のSDPエレメントを含むバイトストリームへのポインタ。
cbSdpStreamLengthDWORDinpSdpStreamのバイト長。
pDataSDP_ELEMENT_DATA*out解析結果のSDPエレメントデータを受け取る構造体ポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD BluetoothSdpGetElementData(
    BYTE* pSdpStream,
    DWORD cbSdpStreamLength,
    SDP_ELEMENT_DATA* pData
);
[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern uint BluetoothSdpGetElementData(
    IntPtr pSdpStream,   // BYTE*
    uint cbSdpStreamLength,   // DWORD
    IntPtr pData   // SDP_ELEMENT_DATA* out
);
<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothSdpGetElementData(
    pSdpStream As IntPtr,   ' BYTE*
    cbSdpStreamLength As UInteger,   ' DWORD
    pData As IntPtr   ' SDP_ELEMENT_DATA* out
) As UInteger
End Function
' pSdpStream : BYTE*
' cbSdpStreamLength : DWORD
' pData : SDP_ELEMENT_DATA* out
Declare PtrSafe Function BluetoothSdpGetElementData Lib "bluetoothapis" ( _
    ByVal pSdpStream As LongPtr, _
    ByVal cbSdpStreamLength As Long, _
    ByVal pData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BluetoothSdpGetElementData = ctypes.windll.bluetoothapis.BluetoothSdpGetElementData
BluetoothSdpGetElementData.restype = wintypes.DWORD
BluetoothSdpGetElementData.argtypes = [
    ctypes.POINTER(ctypes.c_ubyte),  # pSdpStream : BYTE*
    wintypes.DWORD,  # cbSdpStreamLength : DWORD
    ctypes.c_void_p,  # pData : SDP_ELEMENT_DATA* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothSdpGetElementData = Fiddle::Function.new(
  lib['BluetoothSdpGetElementData'],
  [
    Fiddle::TYPE_VOIDP,  # pSdpStream : BYTE*
    -Fiddle::TYPE_INT,  # cbSdpStreamLength : DWORD
    Fiddle::TYPE_VOIDP,  # pData : SDP_ELEMENT_DATA* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "bluetoothapis")]
extern "system" {
    fn BluetoothSdpGetElementData(
        pSdpStream: *mut u8,  // BYTE*
        cbSdpStreamLength: u32,  // DWORD
        pData: *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 BluetoothSdpGetElementData(IntPtr pSdpStream, uint cbSdpStreamLength, IntPtr pData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothSdpGetElementData' -Namespace Win32 -PassThru
# $api::BluetoothSdpGetElementData(pSdpStream, cbSdpStreamLength, pData)
#uselib "BluetoothApis.dll"
#func global BluetoothSdpGetElementData "BluetoothSdpGetElementData" sptr, sptr, sptr
; BluetoothSdpGetElementData varptr(pSdpStream), cbSdpStreamLength, varptr(pData)   ; 戻り値は stat
; pSdpStream : BYTE* -> "sptr"
; cbSdpStreamLength : DWORD -> "sptr"
; pData : SDP_ELEMENT_DATA* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "BluetoothApis.dll"
#cfunc global BluetoothSdpGetElementData "BluetoothSdpGetElementData" var, int, var
; res = BluetoothSdpGetElementData(pSdpStream, cbSdpStreamLength, pData)
; pSdpStream : BYTE* -> "var"
; cbSdpStreamLength : DWORD -> "int"
; pData : SDP_ELEMENT_DATA* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD BluetoothSdpGetElementData(BYTE* pSdpStream, DWORD cbSdpStreamLength, SDP_ELEMENT_DATA* pData)
#uselib "BluetoothApis.dll"
#cfunc global BluetoothSdpGetElementData "BluetoothSdpGetElementData" var, int, var
; res = BluetoothSdpGetElementData(pSdpStream, cbSdpStreamLength, pData)
; pSdpStream : BYTE* -> "var"
; cbSdpStreamLength : DWORD -> "int"
; pData : SDP_ELEMENT_DATA* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothSdpGetElementData = bluetoothapis.NewProc("BluetoothSdpGetElementData")
)

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

extern "bluetoothapis" fn BluetoothSdpGetElementData(
    pSdpStream: [*c]u8, // BYTE*
    cbSdpStreamLength: u32, // DWORD
    pData: [*c]SDP_ELEMENT_DATA // SDP_ELEMENT_DATA* out
) callconv(std.os.windows.WINAPI) u32;
proc BluetoothSdpGetElementData(
    pSdpStream: ptr uint8,  # BYTE*
    cbSdpStreamLength: uint32,  # DWORD
    pData: ptr SDP_ELEMENT_DATA  # SDP_ELEMENT_DATA* out
): uint32 {.importc: "BluetoothSdpGetElementData", stdcall, dynlib: "BluetoothApis.dll".}
pragma(lib, "bluetoothapis");
extern(Windows)
uint BluetoothSdpGetElementData(
    ubyte* pSdpStream,   // BYTE*
    uint cbSdpStreamLength,   // DWORD
    SDP_ELEMENT_DATA* pData   // SDP_ELEMENT_DATA* out
);
ccall((:BluetoothSdpGetElementData, "BluetoothApis.dll"), stdcall, UInt32,
      (Ptr{UInt8}, UInt32, Ptr{SDP_ELEMENT_DATA}),
      pSdpStream, cbSdpStreamLength, pData)
# pSdpStream : BYTE* -> Ptr{UInt8}
# cbSdpStreamLength : DWORD -> UInt32
# pData : SDP_ELEMENT_DATA* out -> Ptr{SDP_ELEMENT_DATA}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t BluetoothSdpGetElementData(
    uint8_t* pSdpStream,
    uint32_t cbSdpStreamLength,
    void* pData);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothSdpGetElementData(pSdpStream, cbSdpStreamLength, pData)
-- pSdpStream : BYTE*
-- cbSdpStreamLength : DWORD
-- pData : SDP_ELEMENT_DATA* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothSdpGetElementData = lib.func('__stdcall', 'BluetoothSdpGetElementData', 'uint32_t', ['uint8_t *', 'uint32_t', 'void *']);
// BluetoothSdpGetElementData(pSdpStream, cbSdpStreamLength, pData)
// pSdpStream : BYTE* -> 'uint8_t *'
// cbSdpStreamLength : DWORD -> 'uint32_t'
// pData : SDP_ELEMENT_DATA* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("BluetoothApis.dll", {
  BluetoothSdpGetElementData: { parameters: ["pointer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.BluetoothSdpGetElementData(pSdpStream, cbSdpStreamLength, pData)
// pSdpStream : BYTE* -> "pointer"
// cbSdpStreamLength : DWORD -> "u32"
// pData : SDP_ELEMENT_DATA* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t BluetoothSdpGetElementData(
    uint8_t* pSdpStream,
    uint32_t cbSdpStreamLength,
    void* pData);
C, "BluetoothApis.dll");
// $ffi->BluetoothSdpGetElementData(pSdpStream, cbSdpStreamLength, pData);
// pSdpStream : BYTE*
// cbSdpStreamLength : DWORD
// pData : 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 BluetoothSdpGetElementData(
        byte[] pSdpStream,   // BYTE*
        int cbSdpStreamLength,   // DWORD
        Pointer pData   // SDP_ELEMENT_DATA* out
    );
}
@[Link("bluetoothapis")]
lib LibBluetoothApis
  fun BluetoothSdpGetElementData = BluetoothSdpGetElementData(
    pSdpStream : UInt8*,   # BYTE*
    cbSdpStreamLength : UInt32,   # DWORD
    pData : 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 BluetoothSdpGetElementDataNative = Uint32 Function(Pointer<Uint8>, Uint32, Pointer<Void>);
typedef BluetoothSdpGetElementDataDart = int Function(Pointer<Uint8>, int, Pointer<Void>);
final BluetoothSdpGetElementData = DynamicLibrary.open('BluetoothApis.dll')
    .lookupFunction<BluetoothSdpGetElementDataNative, BluetoothSdpGetElementDataDart>('BluetoothSdpGetElementData');
// pSdpStream : BYTE* -> Pointer<Uint8>
// cbSdpStreamLength : DWORD -> Uint32
// pData : SDP_ELEMENT_DATA* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function BluetoothSdpGetElementData(
  pSdpStream: Pointer;   // BYTE*
  cbSdpStreamLength: DWORD;   // DWORD
  pData: Pointer   // SDP_ELEMENT_DATA* out
): DWORD; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothSdpGetElementData';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "BluetoothSdpGetElementData"
  c_BluetoothSdpGetElementData :: Ptr Word8 -> Word32 -> Ptr () -> IO Word32
-- pSdpStream : BYTE* -> Ptr Word8
-- cbSdpStreamLength : DWORD -> Word32
-- pData : SDP_ELEMENT_DATA* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let bluetoothsdpgetelementdata =
  foreign "BluetoothSdpGetElementData"
    ((ptr uint8_t) @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* pSdpStream : BYTE* -> (ptr uint8_t) *)
(* cbSdpStreamLength : DWORD -> uint32_t *)
(* pData : 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 ("BluetoothSdpGetElementData" bluetooth-sdp-get-element-data :convention :stdcall) :uint32
  (p-sdp-stream :pointer)   ; BYTE*
  (cb-sdp-stream-length :uint32)   ; DWORD
  (p-data :pointer))   ; SDP_ELEMENT_DATA* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $BluetoothSdpGetElementData = Win32::API::More->new('BluetoothApis',
    'DWORD BluetoothSdpGetElementData(LPVOID pSdpStream, DWORD cbSdpStreamLength, LPVOID pData)');
# my $ret = $BluetoothSdpGetElementData->Call($pSdpStream, $cbSdpStreamLength, $pData);
# pSdpStream : BYTE* -> LPVOID
# cbSdpStreamLength : DWORD -> DWORD
# pData : SDP_ELEMENT_DATA* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型