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

PeerGraphStartup

関数
ピアグラフィングインフラを初期化し使用を開始する。
DLLP2PGRAPH.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerGraphStartup(
    WORD wVersionRequested,
    PEER_VERSION_DATA* pVersionData
);

パラメーター

名前方向
wVersionRequestedWORDin
pVersionDataPEER_VERSION_DATA*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

PeerGraphStartup = ctypes.windll.p2pgraph.PeerGraphStartup
PeerGraphStartup.restype = ctypes.c_int
PeerGraphStartup.argtypes = [
    ctypes.c_ushort,  # wVersionRequested : WORD
    ctypes.c_void_p,  # pVersionData : PEER_VERSION_DATA* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('P2PGRAPH.dll')
PeerGraphStartup = Fiddle::Function.new(
  lib['PeerGraphStartup'],
  [
    -Fiddle::TYPE_SHORT,  # wVersionRequested : WORD
    Fiddle::TYPE_VOIDP,  # pVersionData : PEER_VERSION_DATA* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "p2pgraph")]
extern "system" {
    fn PeerGraphStartup(
        wVersionRequested: u16,  // WORD
        pVersionData: *mut PEER_VERSION_DATA  // PEER_VERSION_DATA* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("P2PGRAPH.dll")]
public static extern int PeerGraphStartup(ushort wVersionRequested, IntPtr pVersionData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2PGRAPH_PeerGraphStartup' -Namespace Win32 -PassThru
# $api::PeerGraphStartup(wVersionRequested, pVersionData)
#uselib "P2PGRAPH.dll"
#func global PeerGraphStartup "PeerGraphStartup" sptr, sptr
; PeerGraphStartup wVersionRequested, varptr(pVersionData)   ; 戻り値は stat
; wVersionRequested : WORD -> "sptr"
; pVersionData : PEER_VERSION_DATA* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "P2PGRAPH.dll"
#cfunc global PeerGraphStartup "PeerGraphStartup" int, var
; res = PeerGraphStartup(wVersionRequested, pVersionData)
; wVersionRequested : WORD -> "int"
; pVersionData : PEER_VERSION_DATA* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT PeerGraphStartup(WORD wVersionRequested, PEER_VERSION_DATA* pVersionData)
#uselib "P2PGRAPH.dll"
#cfunc global PeerGraphStartup "PeerGraphStartup" int, var
; res = PeerGraphStartup(wVersionRequested, pVersionData)
; wVersionRequested : WORD -> "int"
; pVersionData : PEER_VERSION_DATA* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	p2pgraph = windows.NewLazySystemDLL("P2PGRAPH.dll")
	procPeerGraphStartup = p2pgraph.NewProc("PeerGraphStartup")
)

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