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

PeerPnrpResolve

関数
ピア名をPNRPで解決しエンドポイントを取得する。
DLLP2P.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerPnrpResolve(
    LPCWSTR pcwzPeerName,
    LPCWSTR pcwzCloudName,   // optional
    DWORD* pcEndpoints,
    PEER_PNRP_ENDPOINT_INFO** ppEndpoints
);

パラメーター

名前方向
pcwzPeerNameLPCWSTRin
pcwzCloudNameLPCWSTRinoptional
pcEndpointsDWORD*inout
ppEndpointsPEER_PNRP_ENDPOINT_INFO**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PeerPnrpResolve(
    LPCWSTR pcwzPeerName,
    LPCWSTR pcwzCloudName,   // optional
    DWORD* pcEndpoints,
    PEER_PNRP_ENDPOINT_INFO** ppEndpoints
);
[DllImport("P2P.dll", ExactSpelling = true)]
static extern int PeerPnrpResolve(
    [MarshalAs(UnmanagedType.LPWStr)] string pcwzPeerName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pcwzCloudName,   // LPCWSTR optional
    ref uint pcEndpoints,   // DWORD* in/out
    IntPtr ppEndpoints   // PEER_PNRP_ENDPOINT_INFO** out
);
<DllImport("P2P.dll", ExactSpelling:=True)>
Public Shared Function PeerPnrpResolve(
    <MarshalAs(UnmanagedType.LPWStr)> pcwzPeerName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pcwzCloudName As String,   ' LPCWSTR optional
    ByRef pcEndpoints As UInteger,   ' DWORD* in/out
    ppEndpoints As IntPtr   ' PEER_PNRP_ENDPOINT_INFO** out
) As Integer
End Function
' pcwzPeerName : LPCWSTR
' pcwzCloudName : LPCWSTR optional
' pcEndpoints : DWORD* in/out
' ppEndpoints : PEER_PNRP_ENDPOINT_INFO** out
Declare PtrSafe Function PeerPnrpResolve Lib "p2p" ( _
    ByVal pcwzPeerName As LongPtr, _
    ByVal pcwzCloudName As LongPtr, _
    ByRef pcEndpoints As Long, _
    ByVal ppEndpoints As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PeerPnrpResolve = ctypes.windll.p2p.PeerPnrpResolve
PeerPnrpResolve.restype = ctypes.c_int
PeerPnrpResolve.argtypes = [
    wintypes.LPCWSTR,  # pcwzPeerName : LPCWSTR
    wintypes.LPCWSTR,  # pcwzCloudName : LPCWSTR optional
    ctypes.POINTER(wintypes.DWORD),  # pcEndpoints : DWORD* in/out
    ctypes.c_void_p,  # ppEndpoints : PEER_PNRP_ENDPOINT_INFO** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerPnrpResolve = p2p.NewProc("PeerPnrpResolve")
)

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