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

PeerGraphListen

関数
ピアグラフで着信接続の待ち受けを開始する。
DLLP2PGRAPH.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerGraphListen(
    void* hGraph,
    DWORD dwScope,   // optional
    DWORD dwScopeId,   // optional
    WORD wPort   // optional
);

パラメーター

名前方向
hGraphvoid*in
dwScopeDWORDinoptional
dwScopeIdDWORDinoptional
wPortWORDinoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PeerGraphListen(
    void* hGraph,
    DWORD dwScope,   // optional
    DWORD dwScopeId,   // optional
    WORD wPort   // optional
);
[DllImport("P2PGRAPH.dll", ExactSpelling = true)]
static extern int PeerGraphListen(
    IntPtr hGraph,   // void*
    uint dwScope,   // DWORD optional
    uint dwScopeId,   // DWORD optional
    ushort wPort   // WORD optional
);
<DllImport("P2PGRAPH.dll", ExactSpelling:=True)>
Public Shared Function PeerGraphListen(
    hGraph As IntPtr,   ' void*
    dwScope As UInteger,   ' DWORD optional
    dwScopeId As UInteger,   ' DWORD optional
    wPort As UShort   ' WORD optional
) As Integer
End Function
' hGraph : void*
' dwScope : DWORD optional
' dwScopeId : DWORD optional
' wPort : WORD optional
Declare PtrSafe Function PeerGraphListen Lib "p2pgraph" ( _
    ByVal hGraph As LongPtr, _
    ByVal dwScope As Long, _
    ByVal dwScopeId As Long, _
    ByVal wPort As Integer) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PeerGraphListen = ctypes.windll.p2pgraph.PeerGraphListen
PeerGraphListen.restype = ctypes.c_int
PeerGraphListen.argtypes = [
    ctypes.POINTER(None),  # hGraph : void*
    wintypes.DWORD,  # dwScope : DWORD optional
    wintypes.DWORD,  # dwScopeId : DWORD optional
    ctypes.c_ushort,  # wPort : WORD optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('P2PGRAPH.dll')
PeerGraphListen = Fiddle::Function.new(
  lib['PeerGraphListen'],
  [
    Fiddle::TYPE_VOIDP,  # hGraph : void*
    -Fiddle::TYPE_INT,  # dwScope : DWORD optional
    -Fiddle::TYPE_INT,  # dwScopeId : DWORD optional
    -Fiddle::TYPE_SHORT,  # wPort : WORD optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "p2pgraph")]
extern "system" {
    fn PeerGraphListen(
        hGraph: *mut (),  // void*
        dwScope: u32,  // DWORD optional
        dwScopeId: u32,  // DWORD optional
        wPort: u16  // WORD optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("P2PGRAPH.dll")]
public static extern int PeerGraphListen(IntPtr hGraph, uint dwScope, uint dwScopeId, ushort wPort);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2PGRAPH_PeerGraphListen' -Namespace Win32 -PassThru
# $api::PeerGraphListen(hGraph, dwScope, dwScopeId, wPort)
#uselib "P2PGRAPH.dll"
#func global PeerGraphListen "PeerGraphListen" sptr, sptr, sptr, sptr
; PeerGraphListen hGraph, dwScope, dwScopeId, wPort   ; 戻り値は stat
; hGraph : void* -> "sptr"
; dwScope : DWORD optional -> "sptr"
; dwScopeId : DWORD optional -> "sptr"
; wPort : WORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "P2PGRAPH.dll"
#cfunc global PeerGraphListen "PeerGraphListen" sptr, int, int, int
; res = PeerGraphListen(hGraph, dwScope, dwScopeId, wPort)
; hGraph : void* -> "sptr"
; dwScope : DWORD optional -> "int"
; dwScopeId : DWORD optional -> "int"
; wPort : WORD optional -> "int"
; HRESULT PeerGraphListen(void* hGraph, DWORD dwScope, DWORD dwScopeId, WORD wPort)
#uselib "P2PGRAPH.dll"
#cfunc global PeerGraphListen "PeerGraphListen" intptr, int, int, int
; res = PeerGraphListen(hGraph, dwScope, dwScopeId, wPort)
; hGraph : void* -> "intptr"
; dwScope : DWORD optional -> "int"
; dwScopeId : DWORD optional -> "int"
; wPort : WORD optional -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	p2pgraph = windows.NewLazySystemDLL("P2PGRAPH.dll")
	procPeerGraphListen = p2pgraph.NewProc("PeerGraphListen")
)

// hGraph (void*), dwScope (DWORD optional), dwScopeId (DWORD optional), wPort (WORD optional)
r1, _, err := procPeerGraphListen.Call(
	uintptr(hGraph),
	uintptr(dwScope),
	uintptr(dwScopeId),
	uintptr(wPort),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function PeerGraphListen(
  hGraph: Pointer;   // void*
  dwScope: DWORD;   // DWORD optional
  dwScopeId: DWORD;   // DWORD optional
  wPort: Word   // WORD optional
): Integer; stdcall;
  external 'P2PGRAPH.dll' name 'PeerGraphListen';
result := DllCall("P2PGRAPH\PeerGraphListen"
    , "Ptr", hGraph   ; void*
    , "UInt", dwScope   ; DWORD optional
    , "UInt", dwScopeId   ; DWORD optional
    , "UShort", wPort   ; WORD optional
    , "Int")   ; return: HRESULT
●PeerGraphListen(hGraph, dwScope, dwScopeId, wPort) = DLL("P2PGRAPH.dll", "int PeerGraphListen(void*, dword, dword, int)")
# 呼び出し: PeerGraphListen(hGraph, dwScope, dwScopeId, wPort)
# hGraph : void* -> "void*"
# dwScope : DWORD optional -> "dword"
# dwScopeId : DWORD optional -> "dword"
# wPort : WORD optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。