ホーム › NetworkManagement.P2P › PeerGraphOpenDirectConnection
PeerGraphOpenDirectConnection
関数指定ピアへのダイレクト接続を開く。
シグネチャ
// P2PGRAPH.dll
#include <windows.h>
HRESULT PeerGraphOpenDirectConnection(
void* hGraph,
LPCWSTR pwzPeerId,
PEER_ADDRESS* pAddress,
ULONGLONG* pullConnectionId
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hGraph | void* | in |
| pwzPeerId | LPCWSTR | in |
| pAddress | PEER_ADDRESS* | in |
| pullConnectionId | ULONGLONG* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// P2PGRAPH.dll
#include <windows.h>
HRESULT PeerGraphOpenDirectConnection(
void* hGraph,
LPCWSTR pwzPeerId,
PEER_ADDRESS* pAddress,
ULONGLONG* pullConnectionId
);[DllImport("P2PGRAPH.dll", ExactSpelling = true)]
static extern int PeerGraphOpenDirectConnection(
IntPtr hGraph, // void*
[MarshalAs(UnmanagedType.LPWStr)] string pwzPeerId, // LPCWSTR
IntPtr pAddress, // PEER_ADDRESS*
out ulong pullConnectionId // ULONGLONG* out
);<DllImport("P2PGRAPH.dll", ExactSpelling:=True)>
Public Shared Function PeerGraphOpenDirectConnection(
hGraph As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> pwzPeerId As String, ' LPCWSTR
pAddress As IntPtr, ' PEER_ADDRESS*
<Out> ByRef pullConnectionId As ULong ' ULONGLONG* out
) As Integer
End Function' hGraph : void*
' pwzPeerId : LPCWSTR
' pAddress : PEER_ADDRESS*
' pullConnectionId : ULONGLONG* out
Declare PtrSafe Function PeerGraphOpenDirectConnection 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
PeerGraphOpenDirectConnection = ctypes.windll.p2pgraph.PeerGraphOpenDirectConnection
PeerGraphOpenDirectConnection.restype = ctypes.c_int
PeerGraphOpenDirectConnection.argtypes = [
ctypes.POINTER(None), # hGraph : void*
wintypes.LPCWSTR, # pwzPeerId : LPCWSTR
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')
PeerGraphOpenDirectConnection = Fiddle::Function.new(
lib['PeerGraphOpenDirectConnection'],
[
Fiddle::TYPE_VOIDP, # hGraph : void*
Fiddle::TYPE_VOIDP, # pwzPeerId : LPCWSTR
Fiddle::TYPE_VOIDP, # pAddress : PEER_ADDRESS*
Fiddle::TYPE_VOIDP, # pullConnectionId : ULONGLONG* out
],
Fiddle::TYPE_INT)#[link(name = "p2pgraph")]
extern "system" {
fn PeerGraphOpenDirectConnection(
hGraph: *mut (), // void*
pwzPeerId: *const u16, // LPCWSTR
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 PeerGraphOpenDirectConnection(IntPtr hGraph, [MarshalAs(UnmanagedType.LPWStr)] string pwzPeerId, IntPtr pAddress, out ulong pullConnectionId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2PGRAPH_PeerGraphOpenDirectConnection' -Namespace Win32 -PassThru
# $api::PeerGraphOpenDirectConnection(hGraph, pwzPeerId, pAddress, pullConnectionId)#uselib "P2PGRAPH.dll"
#func global PeerGraphOpenDirectConnection "PeerGraphOpenDirectConnection" sptr, sptr, sptr, sptr
; PeerGraphOpenDirectConnection hGraph, pwzPeerId, varptr(pAddress), varptr(pullConnectionId) ; 戻り値は stat
; hGraph : void* -> "sptr"
; pwzPeerId : LPCWSTR -> "sptr"
; pAddress : PEER_ADDRESS* -> "sptr"
; pullConnectionId : ULONGLONG* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "P2PGRAPH.dll" #cfunc global PeerGraphOpenDirectConnection "PeerGraphOpenDirectConnection" sptr, wstr, var, var ; res = PeerGraphOpenDirectConnection(hGraph, pwzPeerId, pAddress, pullConnectionId) ; hGraph : void* -> "sptr" ; pwzPeerId : LPCWSTR -> "wstr" ; pAddress : PEER_ADDRESS* -> "var" ; pullConnectionId : ULONGLONG* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "P2PGRAPH.dll" #cfunc global PeerGraphOpenDirectConnection "PeerGraphOpenDirectConnection" sptr, wstr, sptr, sptr ; res = PeerGraphOpenDirectConnection(hGraph, pwzPeerId, varptr(pAddress), varptr(pullConnectionId)) ; hGraph : void* -> "sptr" ; pwzPeerId : LPCWSTR -> "wstr" ; pAddress : PEER_ADDRESS* -> "sptr" ; pullConnectionId : ULONGLONG* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT PeerGraphOpenDirectConnection(void* hGraph, LPCWSTR pwzPeerId, PEER_ADDRESS* pAddress, ULONGLONG* pullConnectionId) #uselib "P2PGRAPH.dll" #cfunc global PeerGraphOpenDirectConnection "PeerGraphOpenDirectConnection" intptr, wstr, var, var ; res = PeerGraphOpenDirectConnection(hGraph, pwzPeerId, pAddress, pullConnectionId) ; hGraph : void* -> "intptr" ; pwzPeerId : LPCWSTR -> "wstr" ; pAddress : PEER_ADDRESS* -> "var" ; pullConnectionId : ULONGLONG* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT PeerGraphOpenDirectConnection(void* hGraph, LPCWSTR pwzPeerId, PEER_ADDRESS* pAddress, ULONGLONG* pullConnectionId) #uselib "P2PGRAPH.dll" #cfunc global PeerGraphOpenDirectConnection "PeerGraphOpenDirectConnection" intptr, wstr, intptr, intptr ; res = PeerGraphOpenDirectConnection(hGraph, pwzPeerId, varptr(pAddress), varptr(pullConnectionId)) ; hGraph : void* -> "intptr" ; pwzPeerId : LPCWSTR -> "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")
procPeerGraphOpenDirectConnection = p2pgraph.NewProc("PeerGraphOpenDirectConnection")
)
// hGraph (void*), pwzPeerId (LPCWSTR), pAddress (PEER_ADDRESS*), pullConnectionId (ULONGLONG* out)
r1, _, err := procPeerGraphOpenDirectConnection.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 PeerGraphOpenDirectConnection(
hGraph: Pointer; // void*
pwzPeerId: PWideChar; // LPCWSTR
pAddress: Pointer; // PEER_ADDRESS*
pullConnectionId: Pointer // ULONGLONG* out
): Integer; stdcall;
external 'P2PGRAPH.dll' name 'PeerGraphOpenDirectConnection';result := DllCall("P2PGRAPH\PeerGraphOpenDirectConnection"
, "Ptr", hGraph ; void*
, "WStr", pwzPeerId ; LPCWSTR
, "Ptr", pAddress ; PEER_ADDRESS*
, "Ptr", pullConnectionId ; ULONGLONG* out
, "Int") ; return: HRESULT●PeerGraphOpenDirectConnection(hGraph, pwzPeerId, pAddress, pullConnectionId) = DLL("P2PGRAPH.dll", "int PeerGraphOpenDirectConnection(void*, char*, void*, void*)")
# 呼び出し: PeerGraphOpenDirectConnection(hGraph, pwzPeerId, pAddress, pullConnectionId)
# hGraph : void* -> "void*"
# pwzPeerId : LPCWSTR -> "char*"
# pAddress : PEER_ADDRESS* -> "void*"
# pullConnectionId : ULONGLONG* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。