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

PeerGetNextItem

関数
ピア列挙ハンドルから次の項目群を取得する。
DLLP2P.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerGetNextItem(
    void* hPeerEnum,
    DWORD* pCount,
    void*** pppvItems
);

パラメーター

名前方向
hPeerEnumvoid*in
pCountDWORD*inout
pppvItemsvoid***out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

PeerGetNextItem = ctypes.windll.p2p.PeerGetNextItem
PeerGetNextItem.restype = ctypes.c_int
PeerGetNextItem.argtypes = [
    ctypes.POINTER(None),  # hPeerEnum : void*
    ctypes.POINTER(wintypes.DWORD),  # pCount : DWORD* in/out
    ctypes.c_void_p,  # pppvItems : void*** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerGetNextItem = p2p.NewProc("PeerGetNextItem")
)

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