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

PeerPnrpGetEndpoint

関数
非同期解決で見つかったエンドポイントを取得する。
DLLP2P.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerPnrpGetEndpoint(
    void* hResolve,
    PEER_PNRP_ENDPOINT_INFO** ppEndpoint
);

パラメーター

名前方向
hResolvevoid*in
ppEndpointPEER_PNRP_ENDPOINT_INFO**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PeerPnrpGetEndpoint(
    void* hResolve,
    PEER_PNRP_ENDPOINT_INFO** ppEndpoint
);
[DllImport("P2P.dll", ExactSpelling = true)]
static extern int PeerPnrpGetEndpoint(
    IntPtr hResolve,   // void*
    IntPtr ppEndpoint   // PEER_PNRP_ENDPOINT_INFO** out
);
<DllImport("P2P.dll", ExactSpelling:=True)>
Public Shared Function PeerPnrpGetEndpoint(
    hResolve As IntPtr,   ' void*
    ppEndpoint As IntPtr   ' PEER_PNRP_ENDPOINT_INFO** out
) As Integer
End Function
' hResolve : void*
' ppEndpoint : PEER_PNRP_ENDPOINT_INFO** out
Declare PtrSafe Function PeerPnrpGetEndpoint Lib "p2p" ( _
    ByVal hResolve As LongPtr, _
    ByVal ppEndpoint As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PeerPnrpGetEndpoint = ctypes.windll.p2p.PeerPnrpGetEndpoint
PeerPnrpGetEndpoint.restype = ctypes.c_int
PeerPnrpGetEndpoint.argtypes = [
    ctypes.POINTER(None),  # hResolve : void*
    ctypes.c_void_p,  # ppEndpoint : PEER_PNRP_ENDPOINT_INFO** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerPnrpGetEndpoint = p2p.NewProc("PeerPnrpGetEndpoint")
)

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