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

alljoyn_credentials_setprivatekey

関数
資格情報に秘密鍵を設定する。
DLLMSAJApi.dll呼出規約winapi

シグネチャ

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

void alljoyn_credentials_setprivatekey(
    alljoyn_credentials cred,
    LPCSTR pk
);

パラメーター

名前方向説明
credalljoyn_credentialsin設定対象の資格情報ハンドル。
pkLPCSTRin設定する秘密鍵をPEM形式で表すNULL終端文字列。

戻り値の型: void

各言語での呼び出し定義

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

void alljoyn_credentials_setprivatekey(
    alljoyn_credentials cred,
    LPCSTR pk
);
[DllImport("MSAJApi.dll", ExactSpelling = true)]
static extern void alljoyn_credentials_setprivatekey(
    IntPtr cred,   // alljoyn_credentials
    [MarshalAs(UnmanagedType.LPStr)] string pk   // LPCSTR
);
<DllImport("MSAJApi.dll", ExactSpelling:=True)>
Public Shared Sub alljoyn_credentials_setprivatekey(
    cred As IntPtr,   ' alljoyn_credentials
    <MarshalAs(UnmanagedType.LPStr)> pk As String   ' LPCSTR
)
End Sub
' cred : alljoyn_credentials
' pk : LPCSTR
Declare PtrSafe Sub alljoyn_credentials_setprivatekey Lib "msajapi" ( _
    ByVal cred As LongPtr, _
    ByVal pk As String)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

alljoyn_credentials_setprivatekey = ctypes.windll.msajapi.alljoyn_credentials_setprivatekey
alljoyn_credentials_setprivatekey.restype = None
alljoyn_credentials_setprivatekey.argtypes = [
    ctypes.c_ssize_t,  # cred : alljoyn_credentials
    wintypes.LPCSTR,  # pk : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MSAJApi.dll')
alljoyn_credentials_setprivatekey = Fiddle::Function.new(
  lib['alljoyn_credentials_setprivatekey'],
  [
    Fiddle::TYPE_INTPTR_T,  # cred : alljoyn_credentials
    Fiddle::TYPE_VOIDP,  # pk : LPCSTR
  ],
  Fiddle::TYPE_VOID)
#[link(name = "msajapi")]
extern "system" {
    fn alljoyn_credentials_setprivatekey(
        cred: isize,  // alljoyn_credentials
        pk: *const u8  // LPCSTR
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MSAJApi.dll")]
public static extern void alljoyn_credentials_setprivatekey(IntPtr cred, [MarshalAs(UnmanagedType.LPStr)] string pk);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSAJApi_alljoyn_credentials_setprivatekey' -Namespace Win32 -PassThru
# $api::alljoyn_credentials_setprivatekey(cred, pk)
#uselib "MSAJApi.dll"
#func global alljoyn_credentials_setprivatekey "alljoyn_credentials_setprivatekey" sptr, sptr
; alljoyn_credentials_setprivatekey cred, pk
; cred : alljoyn_credentials -> "sptr"
; pk : LPCSTR -> "sptr"
#uselib "MSAJApi.dll"
#func global alljoyn_credentials_setprivatekey "alljoyn_credentials_setprivatekey" sptr, str
; alljoyn_credentials_setprivatekey cred, pk
; cred : alljoyn_credentials -> "sptr"
; pk : LPCSTR -> "str"
; void alljoyn_credentials_setprivatekey(alljoyn_credentials cred, LPCSTR pk)
#uselib "MSAJApi.dll"
#func global alljoyn_credentials_setprivatekey "alljoyn_credentials_setprivatekey" intptr, str
; alljoyn_credentials_setprivatekey cred, pk
; cred : alljoyn_credentials -> "intptr"
; pk : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msajapi = windows.NewLazySystemDLL("MSAJApi.dll")
	procalljoyn_credentials_setprivatekey = msajapi.NewProc("alljoyn_credentials_setprivatekey")
)

// cred (alljoyn_credentials), pk (LPCSTR)
r1, _, err := procalljoyn_credentials_setprivatekey.Call(
	uintptr(cred),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pk))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure alljoyn_credentials_setprivatekey(
  cred: NativeInt;   // alljoyn_credentials
  pk: PAnsiChar   // LPCSTR
); stdcall;
  external 'MSAJApi.dll' name 'alljoyn_credentials_setprivatekey';
result := DllCall("MSAJApi\alljoyn_credentials_setprivatekey"
    , "Ptr", cred   ; alljoyn_credentials
    , "AStr", pk   ; LPCSTR
    , "Int")   ; return: void
●alljoyn_credentials_setprivatekey(cred, pk) = DLL("MSAJApi.dll", "int alljoyn_credentials_setprivatekey(int, char*)")
# 呼び出し: alljoyn_credentials_setprivatekey(cred, pk)
# cred : alljoyn_credentials -> "int"
# pk : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。