Win32 API 日本語リファレンス
ホームNetworkManagement.P2P › PeerIdentityGetCryptKey

PeerIdentityGetCryptKey

関数
ピアアイデンティティの暗号化キーを取得する。
DLLP2P.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerIdentityGetCryptKey(
    LPCWSTR pwzIdentity,   // optional
    UINT_PTR* phCryptProv
);

パラメーター

名前方向
pwzIdentityLPCWSTRinoptional
phCryptProvUINT_PTR*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PeerIdentityGetCryptKey(
    LPCWSTR pwzIdentity,   // optional
    UINT_PTR* phCryptProv
);
[DllImport("P2P.dll", ExactSpelling = true)]
static extern int PeerIdentityGetCryptKey(
    [MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity,   // LPCWSTR optional
    out UIntPtr phCryptProv   // UINT_PTR* out
);
<DllImport("P2P.dll", ExactSpelling:=True)>
Public Shared Function PeerIdentityGetCryptKey(
    <MarshalAs(UnmanagedType.LPWStr)> pwzIdentity As String,   ' LPCWSTR optional
    <Out> ByRef phCryptProv As UIntPtr   ' UINT_PTR* out
) As Integer
End Function
' pwzIdentity : LPCWSTR optional
' phCryptProv : UINT_PTR* out
Declare PtrSafe Function PeerIdentityGetCryptKey Lib "p2p" ( _
    ByVal pwzIdentity As LongPtr, _
    ByRef phCryptProv As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PeerIdentityGetCryptKey = ctypes.windll.p2p.PeerIdentityGetCryptKey
PeerIdentityGetCryptKey.restype = ctypes.c_int
PeerIdentityGetCryptKey.argtypes = [
    wintypes.LPCWSTR,  # pwzIdentity : LPCWSTR optional
    ctypes.POINTER(ctypes.c_size_t),  # phCryptProv : UINT_PTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('P2P.dll')
PeerIdentityGetCryptKey = Fiddle::Function.new(
  lib['PeerIdentityGetCryptKey'],
  [
    Fiddle::TYPE_VOIDP,  # pwzIdentity : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # phCryptProv : UINT_PTR* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "p2p")]
extern "system" {
    fn PeerIdentityGetCryptKey(
        pwzIdentity: *const u16,  // LPCWSTR optional
        phCryptProv: *mut usize  // UINT_PTR* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("P2P.dll")]
public static extern int PeerIdentityGetCryptKey([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, out UIntPtr phCryptProv);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2P_PeerIdentityGetCryptKey' -Namespace Win32 -PassThru
# $api::PeerIdentityGetCryptKey(pwzIdentity, phCryptProv)
#uselib "P2P.dll"
#func global PeerIdentityGetCryptKey "PeerIdentityGetCryptKey" sptr, sptr
; PeerIdentityGetCryptKey pwzIdentity, varptr(phCryptProv)   ; 戻り値は stat
; pwzIdentity : LPCWSTR optional -> "sptr"
; phCryptProv : UINT_PTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "P2P.dll"
#cfunc global PeerIdentityGetCryptKey "PeerIdentityGetCryptKey" wstr, var
; res = PeerIdentityGetCryptKey(pwzIdentity, phCryptProv)
; pwzIdentity : LPCWSTR optional -> "wstr"
; phCryptProv : UINT_PTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT PeerIdentityGetCryptKey(LPCWSTR pwzIdentity, UINT_PTR* phCryptProv)
#uselib "P2P.dll"
#cfunc global PeerIdentityGetCryptKey "PeerIdentityGetCryptKey" wstr, var
; res = PeerIdentityGetCryptKey(pwzIdentity, phCryptProv)
; pwzIdentity : LPCWSTR optional -> "wstr"
; phCryptProv : UINT_PTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerIdentityGetCryptKey = p2p.NewProc("PeerIdentityGetCryptKey")
)

// pwzIdentity (LPCWSTR optional), phCryptProv (UINT_PTR* out)
r1, _, err := procPeerIdentityGetCryptKey.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzIdentity))),
	uintptr(phCryptProv),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function PeerIdentityGetCryptKey(
  pwzIdentity: PWideChar;   // LPCWSTR optional
  phCryptProv: Pointer   // UINT_PTR* out
): Integer; stdcall;
  external 'P2P.dll' name 'PeerIdentityGetCryptKey';
result := DllCall("P2P\PeerIdentityGetCryptKey"
    , "WStr", pwzIdentity   ; LPCWSTR optional
    , "Ptr", phCryptProv   ; UINT_PTR* out
    , "Int")   ; return: HRESULT
●PeerIdentityGetCryptKey(pwzIdentity, phCryptProv) = DLL("P2P.dll", "int PeerIdentityGetCryptKey(char*, void*)")
# 呼び出し: PeerIdentityGetCryptKey(pwzIdentity, phCryptProv)
# pwzIdentity : LPCWSTR optional -> "char*"
# phCryptProv : UINT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。