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