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

PeerIdentityImport

関数
XMLからピアアイデンティティを取り込む。
DLLP2P.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerIdentityImport(
    LPCWSTR pwzImportXML,
    LPCWSTR pwzPassword,
    LPWSTR* ppwzIdentity
);

パラメーター

名前方向
pwzImportXMLLPCWSTRin
pwzPasswordLPCWSTRin
ppwzIdentityLPWSTR*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PeerIdentityImport(
    LPCWSTR pwzImportXML,
    LPCWSTR pwzPassword,
    LPWSTR* ppwzIdentity
);
[DllImport("P2P.dll", ExactSpelling = true)]
static extern int PeerIdentityImport(
    [MarshalAs(UnmanagedType.LPWStr)] string pwzImportXML,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pwzPassword,   // LPCWSTR
    IntPtr ppwzIdentity   // LPWSTR* out
);
<DllImport("P2P.dll", ExactSpelling:=True)>
Public Shared Function PeerIdentityImport(
    <MarshalAs(UnmanagedType.LPWStr)> pwzImportXML As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pwzPassword As String,   ' LPCWSTR
    ppwzIdentity As IntPtr   ' LPWSTR* out
) As Integer
End Function
' pwzImportXML : LPCWSTR
' pwzPassword : LPCWSTR
' ppwzIdentity : LPWSTR* out
Declare PtrSafe Function PeerIdentityImport Lib "p2p" ( _
    ByVal pwzImportXML As LongPtr, _
    ByVal pwzPassword 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

PeerIdentityImport = ctypes.windll.p2p.PeerIdentityImport
PeerIdentityImport.restype = ctypes.c_int
PeerIdentityImport.argtypes = [
    wintypes.LPCWSTR,  # pwzImportXML : LPCWSTR
    wintypes.LPCWSTR,  # pwzPassword : LPCWSTR
    ctypes.c_void_p,  # ppwzIdentity : LPWSTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('P2P.dll')
PeerIdentityImport = Fiddle::Function.new(
  lib['PeerIdentityImport'],
  [
    Fiddle::TYPE_VOIDP,  # pwzImportXML : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pwzPassword : LPCWSTR
    Fiddle::TYPE_VOIDP,  # ppwzIdentity : LPWSTR* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "p2p")]
extern "system" {
    fn PeerIdentityImport(
        pwzImportXML: *const u16,  // LPCWSTR
        pwzPassword: *const u16,  // LPCWSTR
        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 PeerIdentityImport([MarshalAs(UnmanagedType.LPWStr)] string pwzImportXML, [MarshalAs(UnmanagedType.LPWStr)] string pwzPassword, IntPtr ppwzIdentity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2P_PeerIdentityImport' -Namespace Win32 -PassThru
# $api::PeerIdentityImport(pwzImportXML, pwzPassword, ppwzIdentity)
#uselib "P2P.dll"
#func global PeerIdentityImport "PeerIdentityImport" sptr, sptr, sptr
; PeerIdentityImport pwzImportXML, pwzPassword, varptr(ppwzIdentity)   ; 戻り値は stat
; pwzImportXML : LPCWSTR -> "sptr"
; pwzPassword : LPCWSTR -> "sptr"
; ppwzIdentity : LPWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "P2P.dll"
#cfunc global PeerIdentityImport "PeerIdentityImport" wstr, wstr, var
; res = PeerIdentityImport(pwzImportXML, pwzPassword, ppwzIdentity)
; pwzImportXML : LPCWSTR -> "wstr"
; pwzPassword : LPCWSTR -> "wstr"
; ppwzIdentity : LPWSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT PeerIdentityImport(LPCWSTR pwzImportXML, LPCWSTR pwzPassword, LPWSTR* ppwzIdentity)
#uselib "P2P.dll"
#cfunc global PeerIdentityImport "PeerIdentityImport" wstr, wstr, var
; res = PeerIdentityImport(pwzImportXML, pwzPassword, ppwzIdentity)
; pwzImportXML : LPCWSTR -> "wstr"
; pwzPassword : LPCWSTR -> "wstr"
; ppwzIdentity : LPWSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerIdentityImport = p2p.NewProc("PeerIdentityImport")
)

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