ホーム › Devices.AllJoyn › alljoyn_busattachment_enablepeersecurity
alljoyn_busattachment_enablepeersecurity
関数認証機構を指定してピア間のセキュリティを有効化する。
シグネチャ
// MSAJApi.dll
#include <windows.h>
QStatus alljoyn_busattachment_enablepeersecurity(
alljoyn_busattachment bus,
LPCSTR authMechanisms,
alljoyn_authlistener listener,
LPCSTR keyStoreFileName,
INT isShared
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| bus | alljoyn_busattachment | in | 操作対象のバスアタッチメントハンドル。AllJoyn接続を表す。 |
| authMechanisms | LPCSTR | in | 有効化する認証メカニズム名の空白区切りリスト。ALLJOYN_SRP等を指定する。 |
| listener | alljoyn_authlistener | in | 認証時の資格情報要求を処理する認証リスナハンドル。 |
| keyStoreFileName | LPCSTR | in | 鍵ストアファイルのパス。NULL指定で既定の場所を使用する。 |
| isShared | INT | in | 鍵ストアを複数アプリで共有するか。非0で共有を有効にする。 |
戻り値の型: QStatus
各言語での呼び出し定義
// MSAJApi.dll
#include <windows.h>
QStatus alljoyn_busattachment_enablepeersecurity(
alljoyn_busattachment bus,
LPCSTR authMechanisms,
alljoyn_authlistener listener,
LPCSTR keyStoreFileName,
INT isShared
);[DllImport("MSAJApi.dll", ExactSpelling = true)]
static extern int alljoyn_busattachment_enablepeersecurity(
IntPtr bus, // alljoyn_busattachment
[MarshalAs(UnmanagedType.LPStr)] string authMechanisms, // LPCSTR
IntPtr listener, // alljoyn_authlistener
[MarshalAs(UnmanagedType.LPStr)] string keyStoreFileName, // LPCSTR
int isShared // INT
);<DllImport("MSAJApi.dll", ExactSpelling:=True)>
Public Shared Function alljoyn_busattachment_enablepeersecurity(
bus As IntPtr, ' alljoyn_busattachment
<MarshalAs(UnmanagedType.LPStr)> authMechanisms As String, ' LPCSTR
listener As IntPtr, ' alljoyn_authlistener
<MarshalAs(UnmanagedType.LPStr)> keyStoreFileName As String, ' LPCSTR
isShared As Integer ' INT
) As Integer
End Function' bus : alljoyn_busattachment
' authMechanisms : LPCSTR
' listener : alljoyn_authlistener
' keyStoreFileName : LPCSTR
' isShared : INT
Declare PtrSafe Function alljoyn_busattachment_enablepeersecurity Lib "msajapi" ( _
ByVal bus As LongPtr, _
ByVal authMechanisms As String, _
ByVal listener As LongPtr, _
ByVal keyStoreFileName As String, _
ByVal isShared As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
alljoyn_busattachment_enablepeersecurity = ctypes.windll.msajapi.alljoyn_busattachment_enablepeersecurity
alljoyn_busattachment_enablepeersecurity.restype = ctypes.c_int
alljoyn_busattachment_enablepeersecurity.argtypes = [
ctypes.c_ssize_t, # bus : alljoyn_busattachment
wintypes.LPCSTR, # authMechanisms : LPCSTR
ctypes.c_ssize_t, # listener : alljoyn_authlistener
wintypes.LPCSTR, # keyStoreFileName : LPCSTR
ctypes.c_int, # isShared : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSAJApi.dll')
alljoyn_busattachment_enablepeersecurity = Fiddle::Function.new(
lib['alljoyn_busattachment_enablepeersecurity'],
[
Fiddle::TYPE_INTPTR_T, # bus : alljoyn_busattachment
Fiddle::TYPE_VOIDP, # authMechanisms : LPCSTR
Fiddle::TYPE_INTPTR_T, # listener : alljoyn_authlistener
Fiddle::TYPE_VOIDP, # keyStoreFileName : LPCSTR
Fiddle::TYPE_INT, # isShared : INT
],
Fiddle::TYPE_INT)#[link(name = "msajapi")]
extern "system" {
fn alljoyn_busattachment_enablepeersecurity(
bus: isize, // alljoyn_busattachment
authMechanisms: *const u8, // LPCSTR
listener: isize, // alljoyn_authlistener
keyStoreFileName: *const u8, // LPCSTR
isShared: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSAJApi.dll")]
public static extern int alljoyn_busattachment_enablepeersecurity(IntPtr bus, [MarshalAs(UnmanagedType.LPStr)] string authMechanisms, IntPtr listener, [MarshalAs(UnmanagedType.LPStr)] string keyStoreFileName, int isShared);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSAJApi_alljoyn_busattachment_enablepeersecurity' -Namespace Win32 -PassThru
# $api::alljoyn_busattachment_enablepeersecurity(bus, authMechanisms, listener, keyStoreFileName, isShared)#uselib "MSAJApi.dll"
#func global alljoyn_busattachment_enablepeersecurity "alljoyn_busattachment_enablepeersecurity" sptr, sptr, sptr, sptr, sptr
; alljoyn_busattachment_enablepeersecurity bus, authMechanisms, listener, keyStoreFileName, isShared ; 戻り値は stat
; bus : alljoyn_busattachment -> "sptr"
; authMechanisms : LPCSTR -> "sptr"
; listener : alljoyn_authlistener -> "sptr"
; keyStoreFileName : LPCSTR -> "sptr"
; isShared : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MSAJApi.dll"
#cfunc global alljoyn_busattachment_enablepeersecurity "alljoyn_busattachment_enablepeersecurity" sptr, str, sptr, str, int
; res = alljoyn_busattachment_enablepeersecurity(bus, authMechanisms, listener, keyStoreFileName, isShared)
; bus : alljoyn_busattachment -> "sptr"
; authMechanisms : LPCSTR -> "str"
; listener : alljoyn_authlistener -> "sptr"
; keyStoreFileName : LPCSTR -> "str"
; isShared : INT -> "int"; QStatus alljoyn_busattachment_enablepeersecurity(alljoyn_busattachment bus, LPCSTR authMechanisms, alljoyn_authlistener listener, LPCSTR keyStoreFileName, INT isShared)
#uselib "MSAJApi.dll"
#cfunc global alljoyn_busattachment_enablepeersecurity "alljoyn_busattachment_enablepeersecurity" intptr, str, intptr, str, int
; res = alljoyn_busattachment_enablepeersecurity(bus, authMechanisms, listener, keyStoreFileName, isShared)
; bus : alljoyn_busattachment -> "intptr"
; authMechanisms : LPCSTR -> "str"
; listener : alljoyn_authlistener -> "intptr"
; keyStoreFileName : LPCSTR -> "str"
; isShared : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msajapi = windows.NewLazySystemDLL("MSAJApi.dll")
procalljoyn_busattachment_enablepeersecurity = msajapi.NewProc("alljoyn_busattachment_enablepeersecurity")
)
// bus (alljoyn_busattachment), authMechanisms (LPCSTR), listener (alljoyn_authlistener), keyStoreFileName (LPCSTR), isShared (INT)
r1, _, err := procalljoyn_busattachment_enablepeersecurity.Call(
uintptr(bus),
uintptr(unsafe.Pointer(windows.BytePtrFromString(authMechanisms))),
uintptr(listener),
uintptr(unsafe.Pointer(windows.BytePtrFromString(keyStoreFileName))),
uintptr(isShared),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // QStatusfunction alljoyn_busattachment_enablepeersecurity(
bus: NativeInt; // alljoyn_busattachment
authMechanisms: PAnsiChar; // LPCSTR
listener: NativeInt; // alljoyn_authlistener
keyStoreFileName: PAnsiChar; // LPCSTR
isShared: Integer // INT
): Integer; stdcall;
external 'MSAJApi.dll' name 'alljoyn_busattachment_enablepeersecurity';result := DllCall("MSAJApi\alljoyn_busattachment_enablepeersecurity"
, "Ptr", bus ; alljoyn_busattachment
, "AStr", authMechanisms ; LPCSTR
, "Ptr", listener ; alljoyn_authlistener
, "AStr", keyStoreFileName ; LPCSTR
, "Int", isShared ; INT
, "Int") ; return: QStatus●alljoyn_busattachment_enablepeersecurity(bus, authMechanisms, listener, keyStoreFileName, isShared) = DLL("MSAJApi.dll", "int alljoyn_busattachment_enablepeersecurity(int, char*, int, char*, int)")
# 呼び出し: alljoyn_busattachment_enablepeersecurity(bus, authMechanisms, listener, keyStoreFileName, isShared)
# bus : alljoyn_busattachment -> "int"
# authMechanisms : LPCSTR -> "char*"
# listener : alljoyn_authlistener -> "int"
# keyStoreFileName : LPCSTR -> "char*"
# isShared : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msajapi" fn alljoyn_busattachment_enablepeersecurity(
bus: isize, // alljoyn_busattachment
authMechanisms: [*c]const u8, // LPCSTR
listener: isize, // alljoyn_authlistener
keyStoreFileName: [*c]const u8, // LPCSTR
isShared: i32 // INT
) callconv(std.os.windows.WINAPI) i32;proc alljoyn_busattachment_enablepeersecurity(
bus: int, # alljoyn_busattachment
authMechanisms: cstring, # LPCSTR
listener: int, # alljoyn_authlistener
keyStoreFileName: cstring, # LPCSTR
isShared: int32 # INT
): int32 {.importc: "alljoyn_busattachment_enablepeersecurity", stdcall, dynlib: "MSAJApi.dll".}pragma(lib, "msajapi");
extern(Windows)
int alljoyn_busattachment_enablepeersecurity(
ptrdiff_t bus, // alljoyn_busattachment
const(char)* authMechanisms, // LPCSTR
ptrdiff_t listener, // alljoyn_authlistener
const(char)* keyStoreFileName, // LPCSTR
int isShared // INT
);ccall((:alljoyn_busattachment_enablepeersecurity, "MSAJApi.dll"), stdcall, Int32,
(Int, Cstring, Int, Cstring, Int32),
bus, authMechanisms, listener, keyStoreFileName, isShared)
# bus : alljoyn_busattachment -> Int
# authMechanisms : LPCSTR -> Cstring
# listener : alljoyn_authlistener -> Int
# keyStoreFileName : LPCSTR -> Cstring
# isShared : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t alljoyn_busattachment_enablepeersecurity(
intptr_t bus,
const char* authMechanisms,
intptr_t listener,
const char* keyStoreFileName,
int32_t isShared);
]]
local msajapi = ffi.load("msajapi")
-- msajapi.alljoyn_busattachment_enablepeersecurity(bus, authMechanisms, listener, keyStoreFileName, isShared)
-- bus : alljoyn_busattachment
-- authMechanisms : LPCSTR
-- listener : alljoyn_authlistener
-- keyStoreFileName : LPCSTR
-- isShared : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MSAJApi.dll');
const alljoyn_busattachment_enablepeersecurity = lib.func('__stdcall', 'alljoyn_busattachment_enablepeersecurity', 'int32_t', ['intptr_t', 'str', 'intptr_t', 'str', 'int32_t']);
// alljoyn_busattachment_enablepeersecurity(bus, authMechanisms, listener, keyStoreFileName, isShared)
// bus : alljoyn_busattachment -> 'intptr_t'
// authMechanisms : LPCSTR -> 'str'
// listener : alljoyn_authlistener -> 'intptr_t'
// keyStoreFileName : LPCSTR -> 'str'
// isShared : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MSAJApi.dll", {
alljoyn_busattachment_enablepeersecurity: { parameters: ["isize", "buffer", "isize", "buffer", "i32"], result: "i32" },
});
// lib.symbols.alljoyn_busattachment_enablepeersecurity(bus, authMechanisms, listener, keyStoreFileName, isShared)
// bus : alljoyn_busattachment -> "isize"
// authMechanisms : LPCSTR -> "buffer"
// listener : alljoyn_authlistener -> "isize"
// keyStoreFileName : LPCSTR -> "buffer"
// isShared : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t alljoyn_busattachment_enablepeersecurity(
intptr_t bus,
const char* authMechanisms,
intptr_t listener,
const char* keyStoreFileName,
int32_t isShared);
C, "MSAJApi.dll");
// $ffi->alljoyn_busattachment_enablepeersecurity(bus, authMechanisms, listener, keyStoreFileName, isShared);
// bus : alljoyn_busattachment
// authMechanisms : LPCSTR
// listener : alljoyn_authlistener
// keyStoreFileName : LPCSTR
// isShared : INT
// 構造体/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);
int alljoyn_busattachment_enablepeersecurity(
long bus, // alljoyn_busattachment
String authMechanisms, // LPCSTR
long listener, // alljoyn_authlistener
String keyStoreFileName, // LPCSTR
int isShared // INT
);
}@[Link("msajapi")]
lib LibMSAJApi
fun alljoyn_busattachment_enablepeersecurity = alljoyn_busattachment_enablepeersecurity(
bus : LibC::SSizeT, # alljoyn_busattachment
authMechanisms : UInt8*, # LPCSTR
listener : LibC::SSizeT, # alljoyn_authlistener
keyStoreFileName : UInt8*, # LPCSTR
isShared : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef alljoyn_busattachment_enablepeersecurityNative = Int32 Function(IntPtr, Pointer<Utf8>, IntPtr, Pointer<Utf8>, Int32);
typedef alljoyn_busattachment_enablepeersecurityDart = int Function(int, Pointer<Utf8>, int, Pointer<Utf8>, int);
final alljoyn_busattachment_enablepeersecurity = DynamicLibrary.open('MSAJApi.dll')
.lookupFunction<alljoyn_busattachment_enablepeersecurityNative, alljoyn_busattachment_enablepeersecurityDart>('alljoyn_busattachment_enablepeersecurity');
// bus : alljoyn_busattachment -> IntPtr
// authMechanisms : LPCSTR -> Pointer<Utf8>
// listener : alljoyn_authlistener -> IntPtr
// keyStoreFileName : LPCSTR -> Pointer<Utf8>
// isShared : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function alljoyn_busattachment_enablepeersecurity(
bus: NativeInt; // alljoyn_busattachment
authMechanisms: PAnsiChar; // LPCSTR
listener: NativeInt; // alljoyn_authlistener
keyStoreFileName: PAnsiChar; // LPCSTR
isShared: Integer // INT
): Integer; stdcall;
external 'MSAJApi.dll' name 'alljoyn_busattachment_enablepeersecurity';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "alljoyn_busattachment_enablepeersecurity"
c_alljoyn_busattachment_enablepeersecurity :: CIntPtr -> CString -> CIntPtr -> CString -> Int32 -> IO Int32
-- bus : alljoyn_busattachment -> CIntPtr
-- authMechanisms : LPCSTR -> CString
-- listener : alljoyn_authlistener -> CIntPtr
-- keyStoreFileName : LPCSTR -> CString
-- isShared : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let alljoyn_busattachment_enablepeersecurity =
foreign "alljoyn_busattachment_enablepeersecurity"
(intptr_t @-> string @-> intptr_t @-> string @-> int32_t @-> returning int32_t)
(* bus : alljoyn_busattachment -> intptr_t *)
(* authMechanisms : LPCSTR -> string *)
(* listener : alljoyn_authlistener -> intptr_t *)
(* keyStoreFileName : LPCSTR -> string *)
(* isShared : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msajapi (t "MSAJApi.dll"))
(cffi:use-foreign-library msajapi)
(cffi:defcfun ("alljoyn_busattachment_enablepeersecurity" alljoyn-busattachment-enablepeersecurity :convention :stdcall) :int32
(bus :int64) ; alljoyn_busattachment
(auth-mechanisms :string) ; LPCSTR
(listener :int64) ; alljoyn_authlistener
(key-store-file-name :string) ; LPCSTR
(is-shared :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $alljoyn_busattachment_enablepeersecurity = Win32::API::More->new('MSAJApi',
'int alljoyn_busattachment_enablepeersecurity(LPARAM bus, LPCSTR authMechanisms, LPARAM listener, LPCSTR keyStoreFileName, int isShared)');
# my $ret = $alljoyn_busattachment_enablepeersecurity->Call($bus, $authMechanisms, $listener, $keyStoreFileName, $isShared);
# bus : alljoyn_busattachment -> LPARAM
# authMechanisms : LPCSTR -> LPCSTR
# listener : alljoyn_authlistener -> LPARAM
# keyStoreFileName : LPCSTR -> LPCSTR
# isShared : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型