ホーム › Devices.AllJoyn › AllJoynSendToBus
AllJoynSendToBus
関数AllJoynバスへデータを送信する。
シグネチャ
// MSAJApi.dll
#include <windows.h>
BOOL AllJoynSendToBus(
HANDLE connectedBusHandle,
const void* buffer, // optional
DWORD bytesToWrite,
DWORD* bytesTransferred, // optional
void* reserved
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| connectedBusHandle | HANDLE | in | 送信先となる接続済みバスのハンドル。 |
| buffer | void* | inoptional | 送信するデータを格納したバッファへのポインタ。 |
| bytesToWrite | DWORD | in | 送信するバイト数。 |
| bytesTransferred | DWORD* | outoptional | 実際に送信されたバイト数を受け取るポインタ。NULL可。 |
| reserved | void* | inout | 予約パラメータ。NULLを指定する。 |
戻り値の型: BOOL
各言語での呼び出し定義
// MSAJApi.dll
#include <windows.h>
BOOL AllJoynSendToBus(
HANDLE connectedBusHandle,
const void* buffer, // optional
DWORD bytesToWrite,
DWORD* bytesTransferred, // optional
void* reserved
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSAJApi.dll", SetLastError = true, ExactSpelling = true)]
static extern bool AllJoynSendToBus(
IntPtr connectedBusHandle, // HANDLE
IntPtr buffer, // void* optional
uint bytesToWrite, // DWORD
IntPtr bytesTransferred, // DWORD* optional, out
IntPtr reserved // void* in/out
);<DllImport("MSAJApi.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AllJoynSendToBus(
connectedBusHandle As IntPtr, ' HANDLE
buffer As IntPtr, ' void* optional
bytesToWrite As UInteger, ' DWORD
bytesTransferred As IntPtr, ' DWORD* optional, out
reserved As IntPtr ' void* in/out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' connectedBusHandle : HANDLE
' buffer : void* optional
' bytesToWrite : DWORD
' bytesTransferred : DWORD* optional, out
' reserved : void* in/out
Declare PtrSafe Function AllJoynSendToBus Lib "msajapi" ( _
ByVal connectedBusHandle As LongPtr, _
ByVal buffer As LongPtr, _
ByVal bytesToWrite As Long, _
ByVal bytesTransferred As LongPtr, _
ByVal reserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
AllJoynSendToBus = ctypes.windll.msajapi.AllJoynSendToBus
AllJoynSendToBus.restype = wintypes.BOOL
AllJoynSendToBus.argtypes = [
wintypes.HANDLE, # connectedBusHandle : HANDLE
ctypes.POINTER(None), # buffer : void* optional
wintypes.DWORD, # bytesToWrite : DWORD
ctypes.POINTER(wintypes.DWORD), # bytesTransferred : DWORD* optional, out
ctypes.POINTER(None), # reserved : void* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSAJApi.dll')
AllJoynSendToBus = Fiddle::Function.new(
lib['AllJoynSendToBus'],
[
Fiddle::TYPE_VOIDP, # connectedBusHandle : HANDLE
Fiddle::TYPE_VOIDP, # buffer : void* optional
-Fiddle::TYPE_INT, # bytesToWrite : DWORD
Fiddle::TYPE_VOIDP, # bytesTransferred : DWORD* optional, out
Fiddle::TYPE_VOIDP, # reserved : void* in/out
],
Fiddle::TYPE_INT)#[link(name = "msajapi")]
extern "system" {
fn AllJoynSendToBus(
connectedBusHandle: *mut core::ffi::c_void, // HANDLE
buffer: *const (), // void* optional
bytesToWrite: u32, // DWORD
bytesTransferred: *mut u32, // DWORD* optional, out
reserved: *mut () // void* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSAJApi.dll", SetLastError = true)]
public static extern bool AllJoynSendToBus(IntPtr connectedBusHandle, IntPtr buffer, uint bytesToWrite, IntPtr bytesTransferred, IntPtr reserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSAJApi_AllJoynSendToBus' -Namespace Win32 -PassThru
# $api::AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved)#uselib "MSAJApi.dll"
#func global AllJoynSendToBus "AllJoynSendToBus" sptr, sptr, sptr, sptr, sptr
; AllJoynSendToBus connectedBusHandle, buffer, bytesToWrite, varptr(bytesTransferred), reserved ; 戻り値は stat
; connectedBusHandle : HANDLE -> "sptr"
; buffer : void* optional -> "sptr"
; bytesToWrite : DWORD -> "sptr"
; bytesTransferred : DWORD* optional, out -> "sptr"
; reserved : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MSAJApi.dll" #cfunc global AllJoynSendToBus "AllJoynSendToBus" sptr, sptr, int, var, sptr ; res = AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved) ; connectedBusHandle : HANDLE -> "sptr" ; buffer : void* optional -> "sptr" ; bytesToWrite : DWORD -> "int" ; bytesTransferred : DWORD* optional, out -> "var" ; reserved : void* in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MSAJApi.dll" #cfunc global AllJoynSendToBus "AllJoynSendToBus" sptr, sptr, int, sptr, sptr ; res = AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, varptr(bytesTransferred), reserved) ; connectedBusHandle : HANDLE -> "sptr" ; buffer : void* optional -> "sptr" ; bytesToWrite : DWORD -> "int" ; bytesTransferred : DWORD* optional, out -> "sptr" ; reserved : void* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL AllJoynSendToBus(HANDLE connectedBusHandle, void* buffer, DWORD bytesToWrite, DWORD* bytesTransferred, void* reserved) #uselib "MSAJApi.dll" #cfunc global AllJoynSendToBus "AllJoynSendToBus" intptr, intptr, int, var, intptr ; res = AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved) ; connectedBusHandle : HANDLE -> "intptr" ; buffer : void* optional -> "intptr" ; bytesToWrite : DWORD -> "int" ; bytesTransferred : DWORD* optional, out -> "var" ; reserved : void* in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL AllJoynSendToBus(HANDLE connectedBusHandle, void* buffer, DWORD bytesToWrite, DWORD* bytesTransferred, void* reserved) #uselib "MSAJApi.dll" #cfunc global AllJoynSendToBus "AllJoynSendToBus" intptr, intptr, int, intptr, intptr ; res = AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, varptr(bytesTransferred), reserved) ; connectedBusHandle : HANDLE -> "intptr" ; buffer : void* optional -> "intptr" ; bytesToWrite : DWORD -> "int" ; bytesTransferred : DWORD* optional, out -> "intptr" ; reserved : void* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msajapi = windows.NewLazySystemDLL("MSAJApi.dll")
procAllJoynSendToBus = msajapi.NewProc("AllJoynSendToBus")
)
// connectedBusHandle (HANDLE), buffer (void* optional), bytesToWrite (DWORD), bytesTransferred (DWORD* optional, out), reserved (void* in/out)
r1, _, err := procAllJoynSendToBus.Call(
uintptr(connectedBusHandle),
uintptr(buffer),
uintptr(bytesToWrite),
uintptr(bytesTransferred),
uintptr(reserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction AllJoynSendToBus(
connectedBusHandle: THandle; // HANDLE
buffer: Pointer; // void* optional
bytesToWrite: DWORD; // DWORD
bytesTransferred: Pointer; // DWORD* optional, out
reserved: Pointer // void* in/out
): BOOL; stdcall;
external 'MSAJApi.dll' name 'AllJoynSendToBus';result := DllCall("MSAJApi\AllJoynSendToBus"
, "Ptr", connectedBusHandle ; HANDLE
, "Ptr", buffer ; void* optional
, "UInt", bytesToWrite ; DWORD
, "Ptr", bytesTransferred ; DWORD* optional, out
, "Ptr", reserved ; void* in/out
, "Int") ; return: BOOL●AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved) = DLL("MSAJApi.dll", "bool AllJoynSendToBus(void*, void*, dword, void*, void*)")
# 呼び出し: AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved)
# connectedBusHandle : HANDLE -> "void*"
# buffer : void* optional -> "void*"
# bytesToWrite : DWORD -> "dword"
# bytesTransferred : DWORD* optional, out -> "void*"
# reserved : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msajapi" fn AllJoynSendToBus(
connectedBusHandle: ?*anyopaque, // HANDLE
buffer: ?*anyopaque, // void* optional
bytesToWrite: u32, // DWORD
bytesTransferred: [*c]u32, // DWORD* optional, out
reserved: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;proc AllJoynSendToBus(
connectedBusHandle: pointer, # HANDLE
buffer: pointer, # void* optional
bytesToWrite: uint32, # DWORD
bytesTransferred: ptr uint32, # DWORD* optional, out
reserved: pointer # void* in/out
): int32 {.importc: "AllJoynSendToBus", stdcall, dynlib: "MSAJApi.dll".}pragma(lib, "msajapi");
extern(Windows)
int AllJoynSendToBus(
void* connectedBusHandle, // HANDLE
void* buffer, // void* optional
uint bytesToWrite, // DWORD
uint* bytesTransferred, // DWORD* optional, out
void* reserved // void* in/out
);ccall((:AllJoynSendToBus, "MSAJApi.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, UInt32, Ptr{UInt32}, Ptr{Cvoid}),
connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved)
# connectedBusHandle : HANDLE -> Ptr{Cvoid}
# buffer : void* optional -> Ptr{Cvoid}
# bytesToWrite : DWORD -> UInt32
# bytesTransferred : DWORD* optional, out -> Ptr{UInt32}
# reserved : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t AllJoynSendToBus(
void* connectedBusHandle,
void* buffer,
uint32_t bytesToWrite,
uint32_t* bytesTransferred,
void* reserved);
]]
local msajapi = ffi.load("msajapi")
-- msajapi.AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved)
-- connectedBusHandle : HANDLE
-- buffer : void* optional
-- bytesToWrite : DWORD
-- bytesTransferred : DWORD* optional, out
-- reserved : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MSAJApi.dll');
const AllJoynSendToBus = lib.func('__stdcall', 'AllJoynSendToBus', 'int32_t', ['void *', 'void *', 'uint32_t', 'uint32_t *', 'void *']);
// AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved)
// connectedBusHandle : HANDLE -> 'void *'
// buffer : void* optional -> 'void *'
// bytesToWrite : DWORD -> 'uint32_t'
// bytesTransferred : DWORD* optional, out -> 'uint32_t *'
// reserved : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MSAJApi.dll", {
AllJoynSendToBus: { parameters: ["pointer", "pointer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved)
// connectedBusHandle : HANDLE -> "pointer"
// buffer : void* optional -> "pointer"
// bytesToWrite : DWORD -> "u32"
// bytesTransferred : DWORD* optional, out -> "pointer"
// reserved : void* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t AllJoynSendToBus(
void* connectedBusHandle,
void* buffer,
uint32_t bytesToWrite,
uint32_t* bytesTransferred,
void* reserved);
C, "MSAJApi.dll");
// $ffi->AllJoynSendToBus(connectedBusHandle, buffer, bytesToWrite, bytesTransferred, reserved);
// connectedBusHandle : HANDLE
// buffer : void* optional
// bytesToWrite : DWORD
// bytesTransferred : DWORD* optional, out
// reserved : void* in/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 Msajapi extends StdCallLibrary {
Msajapi INSTANCE = Native.load("msajapi", Msajapi.class);
boolean AllJoynSendToBus(
Pointer connectedBusHandle, // HANDLE
Pointer buffer, // void* optional
int bytesToWrite, // DWORD
IntByReference bytesTransferred, // DWORD* optional, out
Pointer reserved // void* in/out
);
}@[Link("msajapi")]
lib LibMSAJApi
fun AllJoynSendToBus = AllJoynSendToBus(
connectedBusHandle : Void*, # HANDLE
buffer : Void*, # void* optional
bytesToWrite : UInt32, # DWORD
bytesTransferred : UInt32*, # DWORD* optional, out
reserved : Void* # void* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef AllJoynSendToBusNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Uint32>, Pointer<Void>);
typedef AllJoynSendToBusDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Uint32>, Pointer<Void>);
final AllJoynSendToBus = DynamicLibrary.open('MSAJApi.dll')
.lookupFunction<AllJoynSendToBusNative, AllJoynSendToBusDart>('AllJoynSendToBus');
// connectedBusHandle : HANDLE -> Pointer<Void>
// buffer : void* optional -> Pointer<Void>
// bytesToWrite : DWORD -> Uint32
// bytesTransferred : DWORD* optional, out -> Pointer<Uint32>
// reserved : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function AllJoynSendToBus(
connectedBusHandle: THandle; // HANDLE
buffer: Pointer; // void* optional
bytesToWrite: DWORD; // DWORD
bytesTransferred: Pointer; // DWORD* optional, out
reserved: Pointer // void* in/out
): BOOL; stdcall;
external 'MSAJApi.dll' name 'AllJoynSendToBus';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "AllJoynSendToBus"
c_AllJoynSendToBus :: Ptr () -> Ptr () -> Word32 -> Ptr Word32 -> Ptr () -> IO CInt
-- connectedBusHandle : HANDLE -> Ptr ()
-- buffer : void* optional -> Ptr ()
-- bytesToWrite : DWORD -> Word32
-- bytesTransferred : DWORD* optional, out -> Ptr Word32
-- reserved : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let alljoynsendtobus =
foreign "AllJoynSendToBus"
((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> (ptr void) @-> returning int32_t)
(* connectedBusHandle : HANDLE -> (ptr void) *)
(* buffer : void* optional -> (ptr void) *)
(* bytesToWrite : DWORD -> uint32_t *)
(* bytesTransferred : DWORD* optional, out -> (ptr uint32_t) *)
(* reserved : void* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msajapi (t "MSAJApi.dll"))
(cffi:use-foreign-library msajapi)
(cffi:defcfun ("AllJoynSendToBus" all-joyn-send-to-bus :convention :stdcall) :int32
(connected-bus-handle :pointer) ; HANDLE
(buffer :pointer) ; void* optional
(bytes-to-write :uint32) ; DWORD
(bytes-transferred :pointer) ; DWORD* optional, out
(reserved :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $AllJoynSendToBus = Win32::API::More->new('MSAJApi',
'BOOL AllJoynSendToBus(HANDLE connectedBusHandle, LPVOID buffer, DWORD bytesToWrite, LPVOID bytesTransferred, LPVOID reserved)');
# my $ret = $AllJoynSendToBus->Call($connectedBusHandle, $buffer, $bytesToWrite, $bytesTransferred, $reserved);
# connectedBusHandle : HANDLE -> HANDLE
# buffer : void* optional -> LPVOID
# bytesToWrite : DWORD -> DWORD
# bytesTransferred : DWORD* optional, out -> LPVOID
# reserved : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。