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

PeerIdentityCreate

関数
新しいピアアイデンティティを作成する。
DLLP2P.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerIdentityCreate(
    LPCWSTR pwzClassifier,   // optional
    LPCWSTR pwzFriendlyName,   // optional
    UINT_PTR hCryptProv,   // optional
    LPWSTR* ppwzIdentity
);

パラメーター

名前方向
pwzClassifierLPCWSTRinoptional
pwzFriendlyNameLPCWSTRinoptional
hCryptProvUINT_PTRinoptional
ppwzIdentityLPWSTR*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

PeerIdentityCreate = ctypes.windll.p2p.PeerIdentityCreate
PeerIdentityCreate.restype = ctypes.c_int
PeerIdentityCreate.argtypes = [
    wintypes.LPCWSTR,  # pwzClassifier : LPCWSTR optional
    wintypes.LPCWSTR,  # pwzFriendlyName : LPCWSTR optional
    ctypes.c_size_t,  # hCryptProv : UINT_PTR optional
    ctypes.c_void_p,  # ppwzIdentity : LPWSTR* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerIdentityCreate = p2p.NewProc("PeerIdentityCreate")
)

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