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

BluetoothSdpGetString

関数
SDPレコードから指定オフセットの文字列を取得する。
DLLBluetoothApis.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD BluetoothSdpGetString(
    BYTE* pRecordStream,
    DWORD cbRecordLength,
    const SDP_STRING_TYPE_DATA* pStringData,   // optional
    WORD usStringOffset,
    LPWSTR pszString,
    DWORD* pcchStringLength
);

パラメーター

名前方向
pRecordStreamBYTE*in
cbRecordLengthDWORDin
pStringDataSDP_STRING_TYPE_DATA*inoptional
usStringOffsetWORDin
pszStringLPWSTRout
pcchStringLengthDWORD*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD BluetoothSdpGetString(
    BYTE* pRecordStream,
    DWORD cbRecordLength,
    const SDP_STRING_TYPE_DATA* pStringData,   // optional
    WORD usStringOffset,
    LPWSTR pszString,
    DWORD* pcchStringLength
);
[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern uint BluetoothSdpGetString(
    IntPtr pRecordStream,   // BYTE*
    uint cbRecordLength,   // DWORD
    IntPtr pStringData,   // SDP_STRING_TYPE_DATA* optional
    ushort usStringOffset,   // WORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszString,   // LPWSTR out
    ref uint pcchStringLength   // DWORD* in/out
);
<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothSdpGetString(
    pRecordStream As IntPtr,   ' BYTE*
    cbRecordLength As UInteger,   ' DWORD
    pStringData As IntPtr,   ' SDP_STRING_TYPE_DATA* optional
    usStringOffset As UShort,   ' WORD
    <MarshalAs(UnmanagedType.LPWStr)> pszString As System.Text.StringBuilder,   ' LPWSTR out
    ByRef pcchStringLength As UInteger   ' DWORD* in/out
) As UInteger
End Function
' pRecordStream : BYTE*
' cbRecordLength : DWORD
' pStringData : SDP_STRING_TYPE_DATA* optional
' usStringOffset : WORD
' pszString : LPWSTR out
' pcchStringLength : DWORD* in/out
Declare PtrSafe Function BluetoothSdpGetString Lib "bluetoothapis" ( _
    ByVal pRecordStream As LongPtr, _
    ByVal cbRecordLength As Long, _
    ByVal pStringData As LongPtr, _
    ByVal usStringOffset As Integer, _
    ByVal pszString As LongPtr, _
    ByRef pcchStringLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BluetoothSdpGetString = ctypes.windll.bluetoothapis.BluetoothSdpGetString
BluetoothSdpGetString.restype = wintypes.DWORD
BluetoothSdpGetString.argtypes = [
    ctypes.POINTER(ctypes.c_ubyte),  # pRecordStream : BYTE*
    wintypes.DWORD,  # cbRecordLength : DWORD
    ctypes.c_void_p,  # pStringData : SDP_STRING_TYPE_DATA* optional
    ctypes.c_ushort,  # usStringOffset : WORD
    wintypes.LPWSTR,  # pszString : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # pcchStringLength : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothSdpGetString = Fiddle::Function.new(
  lib['BluetoothSdpGetString'],
  [
    Fiddle::TYPE_VOIDP,  # pRecordStream : BYTE*
    -Fiddle::TYPE_INT,  # cbRecordLength : DWORD
    Fiddle::TYPE_VOIDP,  # pStringData : SDP_STRING_TYPE_DATA* optional
    -Fiddle::TYPE_SHORT,  # usStringOffset : WORD
    Fiddle::TYPE_VOIDP,  # pszString : LPWSTR out
    Fiddle::TYPE_VOIDP,  # pcchStringLength : DWORD* in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "bluetoothapis")]
extern "system" {
    fn BluetoothSdpGetString(
        pRecordStream: *mut u8,  // BYTE*
        cbRecordLength: u32,  // DWORD
        pStringData: *const SDP_STRING_TYPE_DATA,  // SDP_STRING_TYPE_DATA* optional
        usStringOffset: u16,  // WORD
        pszString: *mut u16,  // LPWSTR out
        pcchStringLength: *mut u32  // DWORD* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("BluetoothApis.dll")]
public static extern uint BluetoothSdpGetString(IntPtr pRecordStream, uint cbRecordLength, IntPtr pStringData, ushort usStringOffset, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszString, ref uint pcchStringLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothSdpGetString' -Namespace Win32 -PassThru
# $api::BluetoothSdpGetString(pRecordStream, cbRecordLength, pStringData, usStringOffset, pszString, pcchStringLength)
#uselib "BluetoothApis.dll"
#func global BluetoothSdpGetString "BluetoothSdpGetString" sptr, sptr, sptr, sptr, sptr, sptr
; BluetoothSdpGetString varptr(pRecordStream), cbRecordLength, varptr(pStringData), usStringOffset, varptr(pszString), varptr(pcchStringLength)   ; 戻り値は stat
; pRecordStream : BYTE* -> "sptr"
; cbRecordLength : DWORD -> "sptr"
; pStringData : SDP_STRING_TYPE_DATA* optional -> "sptr"
; usStringOffset : WORD -> "sptr"
; pszString : LPWSTR out -> "sptr"
; pcchStringLength : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "BluetoothApis.dll"
#cfunc global BluetoothSdpGetString "BluetoothSdpGetString" var, int, var, int, var, var
; res = BluetoothSdpGetString(pRecordStream, cbRecordLength, pStringData, usStringOffset, pszString, pcchStringLength)
; pRecordStream : BYTE* -> "var"
; cbRecordLength : DWORD -> "int"
; pStringData : SDP_STRING_TYPE_DATA* optional -> "var"
; usStringOffset : WORD -> "int"
; pszString : LPWSTR out -> "var"
; pcchStringLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD BluetoothSdpGetString(BYTE* pRecordStream, DWORD cbRecordLength, SDP_STRING_TYPE_DATA* pStringData, WORD usStringOffset, LPWSTR pszString, DWORD* pcchStringLength)
#uselib "BluetoothApis.dll"
#cfunc global BluetoothSdpGetString "BluetoothSdpGetString" var, int, var, int, var, var
; res = BluetoothSdpGetString(pRecordStream, cbRecordLength, pStringData, usStringOffset, pszString, pcchStringLength)
; pRecordStream : BYTE* -> "var"
; cbRecordLength : DWORD -> "int"
; pStringData : SDP_STRING_TYPE_DATA* optional -> "var"
; usStringOffset : WORD -> "int"
; pszString : LPWSTR out -> "var"
; pcchStringLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothSdpGetString = bluetoothapis.NewProc("BluetoothSdpGetString")
)

// pRecordStream (BYTE*), cbRecordLength (DWORD), pStringData (SDP_STRING_TYPE_DATA* optional), usStringOffset (WORD), pszString (LPWSTR out), pcchStringLength (DWORD* in/out)
r1, _, err := procBluetoothSdpGetString.Call(
	uintptr(pRecordStream),
	uintptr(cbRecordLength),
	uintptr(pStringData),
	uintptr(usStringOffset),
	uintptr(pszString),
	uintptr(pcchStringLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function BluetoothSdpGetString(
  pRecordStream: Pointer;   // BYTE*
  cbRecordLength: DWORD;   // DWORD
  pStringData: Pointer;   // SDP_STRING_TYPE_DATA* optional
  usStringOffset: Word;   // WORD
  pszString: PWideChar;   // LPWSTR out
  pcchStringLength: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothSdpGetString';
result := DllCall("BluetoothApis\BluetoothSdpGetString"
    , "Ptr", pRecordStream   ; BYTE*
    , "UInt", cbRecordLength   ; DWORD
    , "Ptr", pStringData   ; SDP_STRING_TYPE_DATA* optional
    , "UShort", usStringOffset   ; WORD
    , "Ptr", pszString   ; LPWSTR out
    , "Ptr", pcchStringLength   ; DWORD* in/out
    , "UInt")   ; return: DWORD
●BluetoothSdpGetString(pRecordStream, cbRecordLength, pStringData, usStringOffset, pszString, pcchStringLength) = DLL("BluetoothApis.dll", "dword BluetoothSdpGetString(void*, dword, void*, int, char*, void*)")
# 呼び出し: BluetoothSdpGetString(pRecordStream, cbRecordLength, pStringData, usStringOffset, pszString, pcchStringLength)
# pRecordStream : BYTE* -> "void*"
# cbRecordLength : DWORD -> "dword"
# pStringData : SDP_STRING_TYPE_DATA* optional -> "void*"
# usStringOffset : WORD -> "int"
# pszString : LPWSTR out -> "char*"
# pcchStringLength : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。