ホーム › NetworkManagement.P2P › PeerGraphConnect
PeerGraphConnect
関数指定したピアノードへの接続を確立する。
シグネチャ
// P2PGRAPH.dll
#include <windows.h>
HRESULT PeerGraphConnect(
void* hGraph,
LPCWSTR pwzPeerId, // optional
PEER_ADDRESS* pAddress,
ULONGLONG* pullConnectionId
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hGraph | void* | in |
| pwzPeerId | LPCWSTR | inoptional |
| pAddress | PEER_ADDRESS* | in |
| pullConnectionId | ULONGLONG* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// P2PGRAPH.dll
#include <windows.h>
HRESULT PeerGraphConnect(
void* hGraph,
LPCWSTR pwzPeerId, // optional
PEER_ADDRESS* pAddress,
ULONGLONG* pullConnectionId
);[DllImport("P2PGRAPH.dll", ExactSpelling = true)]
static extern int PeerGraphConnect(
IntPtr hGraph, // void*
[MarshalAs(UnmanagedType.LPWStr)] string pwzPeerId, // LPCWSTR optional
IntPtr pAddress, // PEER_ADDRESS*
out ulong pullConnectionId // ULONGLONG* out
);<DllImport("P2PGRAPH.dll", ExactSpelling:=True)>
Public Shared Function PeerGraphConnect(
hGraph As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> pwzPeerId As String, ' LPCWSTR optional
pAddress As IntPtr, ' PEER_ADDRESS*
<Out> ByRef pullConnectionId As ULong ' ULONGLONG* out
) As Integer
End Function' hGraph : void*
' pwzPeerId : LPCWSTR optional
' pAddress : PEER_ADDRESS*
' pullConnectionId : ULONGLONG* out
Declare PtrSafe Function PeerGraphConnect Lib "p2pgraph" ( _
ByVal hGraph As LongPtr, _
ByVal pwzPeerId As LongPtr, _
ByVal pAddress As LongPtr, _
ByRef pullConnectionId As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PeerGraphConnect = ctypes.windll.p2pgraph.PeerGraphConnect
PeerGraphConnect.restype = ctypes.c_int
PeerGraphConnect.argtypes = [
ctypes.POINTER(None), # hGraph : void*
wintypes.LPCWSTR, # pwzPeerId : LPCWSTR optional
ctypes.c_void_p, # pAddress : PEER_ADDRESS*
ctypes.POINTER(ctypes.c_ulonglong), # pullConnectionId : ULONGLONG* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('P2PGRAPH.dll')
PeerGraphConnect = Fiddle::Function.new(
lib['PeerGraphConnect'],
[
Fiddle::TYPE_VOIDP, # hGraph : void*
Fiddle::TYPE_VOIDP, # pwzPeerId : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pAddress : PEER_ADDRESS*
Fiddle::TYPE_VOIDP, # pullConnectionId : ULONGLONG* out
],
Fiddle::TYPE_INT)#[link(name = "p2pgraph")]
extern "system" {
fn PeerGraphConnect(
hGraph: *mut (), // void*
pwzPeerId: *const u16, // LPCWSTR optional
pAddress: *mut PEER_ADDRESS, // PEER_ADDRESS*
pullConnectionId: *mut u64 // ULONGLONG* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("P2PGRAPH.dll")]
public static extern int PeerGraphConnect(IntPtr hGraph, [MarshalAs(UnmanagedType.LPWStr)] string pwzPeerId, IntPtr pAddress, out ulong pullConnectionId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2PGRAPH_PeerGraphConnect' -Namespace Win32 -PassThru
# $api::PeerGraphConnect(hGraph, pwzPeerId, pAddress, pullConnectionId)#uselib "P2PGRAPH.dll"
#func global PeerGraphConnect "PeerGraphConnect" sptr, sptr, sptr, sptr
; PeerGraphConnect hGraph, pwzPeerId, varptr(pAddress), varptr(pullConnectionId) ; 戻り値は stat
; hGraph : void* -> "sptr"
; pwzPeerId : LPCWSTR optional -> "sptr"
; pAddress : PEER_ADDRESS* -> "sptr"
; pullConnectionId : ULONGLONG* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "P2PGRAPH.dll" #cfunc global PeerGraphConnect "PeerGraphConnect" sptr, wstr, var, var ; res = PeerGraphConnect(hGraph, pwzPeerId, pAddress, pullConnectionId) ; hGraph : void* -> "sptr" ; pwzPeerId : LPCWSTR optional -> "wstr" ; pAddress : PEER_ADDRESS* -> "var" ; pullConnectionId : ULONGLONG* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "P2PGRAPH.dll" #cfunc global PeerGraphConnect "PeerGraphConnect" sptr, wstr, sptr, sptr ; res = PeerGraphConnect(hGraph, pwzPeerId, varptr(pAddress), varptr(pullConnectionId)) ; hGraph : void* -> "sptr" ; pwzPeerId : LPCWSTR optional -> "wstr" ; pAddress : PEER_ADDRESS* -> "sptr" ; pullConnectionId : ULONGLONG* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT PeerGraphConnect(void* hGraph, LPCWSTR pwzPeerId, PEER_ADDRESS* pAddress, ULONGLONG* pullConnectionId) #uselib "P2PGRAPH.dll" #cfunc global PeerGraphConnect "PeerGraphConnect" intptr, wstr, var, var ; res = PeerGraphConnect(hGraph, pwzPeerId, pAddress, pullConnectionId) ; hGraph : void* -> "intptr" ; pwzPeerId : LPCWSTR optional -> "wstr" ; pAddress : PEER_ADDRESS* -> "var" ; pullConnectionId : ULONGLONG* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT PeerGraphConnect(void* hGraph, LPCWSTR pwzPeerId, PEER_ADDRESS* pAddress, ULONGLONG* pullConnectionId) #uselib "P2PGRAPH.dll" #cfunc global PeerGraphConnect "PeerGraphConnect" intptr, wstr, intptr, intptr ; res = PeerGraphConnect(hGraph, pwzPeerId, varptr(pAddress), varptr(pullConnectionId)) ; hGraph : void* -> "intptr" ; pwzPeerId : LPCWSTR optional -> "wstr" ; pAddress : PEER_ADDRESS* -> "intptr" ; pullConnectionId : ULONGLONG* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
p2pgraph = windows.NewLazySystemDLL("P2PGRAPH.dll")
procPeerGraphConnect = p2pgraph.NewProc("PeerGraphConnect")
)
// hGraph (void*), pwzPeerId (LPCWSTR optional), pAddress (PEER_ADDRESS*), pullConnectionId (ULONGLONG* out)
r1, _, err := procPeerGraphConnect.Call(
uintptr(hGraph),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzPeerId))),
uintptr(pAddress),
uintptr(pullConnectionId),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction PeerGraphConnect(
hGraph: Pointer; // void*
pwzPeerId: PWideChar; // LPCWSTR optional
pAddress: Pointer; // PEER_ADDRESS*
pullConnectionId: Pointer // ULONGLONG* out
): Integer; stdcall;
external 'P2PGRAPH.dll' name 'PeerGraphConnect';result := DllCall("P2PGRAPH\PeerGraphConnect"
, "Ptr", hGraph ; void*
, "WStr", pwzPeerId ; LPCWSTR optional
, "Ptr", pAddress ; PEER_ADDRESS*
, "Ptr", pullConnectionId ; ULONGLONG* out
, "Int") ; return: HRESULT●PeerGraphConnect(hGraph, pwzPeerId, pAddress, pullConnectionId) = DLL("P2PGRAPH.dll", "int PeerGraphConnect(void*, char*, void*, void*)")
# 呼び出し: PeerGraphConnect(hGraph, pwzPeerId, pAddress, pullConnectionId)
# hGraph : void* -> "void*"
# pwzPeerId : LPCWSTR optional -> "char*"
# pAddress : PEER_ADDRESS* -> "void*"
# pullConnectionId : ULONGLONG* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。