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

PeerPnrpStartResolve

関数
PNRPによるピア名の非同期解決を開始する。
DLLP2P.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerPnrpStartResolve(
    LPCWSTR pcwzPeerName,
    LPCWSTR pcwzCloudName,   // optional
    DWORD cMaxEndpoints,   // optional
    HANDLE hEvent,
    void** phResolve
);

パラメーター

名前方向説明
pcwzPeerNameLPCWSTRin非同期解決するピア名を指すワイド文字列。NULL不可。
pcwzCloudNameLPCWSTRinoptional検索対象のクラウド名。NULLで全クラウドを対象とする。
cMaxEndpointsDWORDinoptional取得する最大エンドポイント数。
hEventHANDLEin結果到着時にシグナルされるイベントハンドル。完了通知に使う。
phResolvevoid**out非同期解決ハンドルを受け取るポインタ。後続のGet/End呼び出しに使用する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PeerPnrpStartResolve(
    LPCWSTR pcwzPeerName,
    LPCWSTR pcwzCloudName,   // optional
    DWORD cMaxEndpoints,   // optional
    HANDLE hEvent,
    void** phResolve
);
[DllImport("P2P.dll", ExactSpelling = true)]
static extern int PeerPnrpStartResolve(
    [MarshalAs(UnmanagedType.LPWStr)] string pcwzPeerName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pcwzCloudName,   // LPCWSTR optional
    uint cMaxEndpoints,   // DWORD optional
    IntPtr hEvent,   // HANDLE
    IntPtr phResolve   // void** out
);
<DllImport("P2P.dll", ExactSpelling:=True)>
Public Shared Function PeerPnrpStartResolve(
    <MarshalAs(UnmanagedType.LPWStr)> pcwzPeerName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pcwzCloudName As String,   ' LPCWSTR optional
    cMaxEndpoints As UInteger,   ' DWORD optional
    hEvent As IntPtr,   ' HANDLE
    phResolve As IntPtr   ' void** out
) As Integer
End Function
' pcwzPeerName : LPCWSTR
' pcwzCloudName : LPCWSTR optional
' cMaxEndpoints : DWORD optional
' hEvent : HANDLE
' phResolve : void** out
Declare PtrSafe Function PeerPnrpStartResolve Lib "p2p" ( _
    ByVal pcwzPeerName As LongPtr, _
    ByVal pcwzCloudName As LongPtr, _
    ByVal cMaxEndpoints As Long, _
    ByVal hEvent As LongPtr, _
    ByVal phResolve As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PeerPnrpStartResolve = ctypes.windll.p2p.PeerPnrpStartResolve
PeerPnrpStartResolve.restype = ctypes.c_int
PeerPnrpStartResolve.argtypes = [
    wintypes.LPCWSTR,  # pcwzPeerName : LPCWSTR
    wintypes.LPCWSTR,  # pcwzCloudName : LPCWSTR optional
    wintypes.DWORD,  # cMaxEndpoints : DWORD optional
    wintypes.HANDLE,  # hEvent : HANDLE
    ctypes.c_void_p,  # phResolve : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('P2P.dll')
PeerPnrpStartResolve = Fiddle::Function.new(
  lib['PeerPnrpStartResolve'],
  [
    Fiddle::TYPE_VOIDP,  # pcwzPeerName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pcwzCloudName : LPCWSTR optional
    -Fiddle::TYPE_INT,  # cMaxEndpoints : DWORD optional
    Fiddle::TYPE_VOIDP,  # hEvent : HANDLE
    Fiddle::TYPE_VOIDP,  # phResolve : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "p2p")]
extern "system" {
    fn PeerPnrpStartResolve(
        pcwzPeerName: *const u16,  // LPCWSTR
        pcwzCloudName: *const u16,  // LPCWSTR optional
        cMaxEndpoints: u32,  // DWORD optional
        hEvent: *mut core::ffi::c_void,  // HANDLE
        phResolve: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("P2P.dll")]
public static extern int PeerPnrpStartResolve([MarshalAs(UnmanagedType.LPWStr)] string pcwzPeerName, [MarshalAs(UnmanagedType.LPWStr)] string pcwzCloudName, uint cMaxEndpoints, IntPtr hEvent, IntPtr phResolve);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2P_PeerPnrpStartResolve' -Namespace Win32 -PassThru
# $api::PeerPnrpStartResolve(pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve)
#uselib "P2P.dll"
#func global PeerPnrpStartResolve "PeerPnrpStartResolve" sptr, sptr, sptr, sptr, sptr
; PeerPnrpStartResolve pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve   ; 戻り値は stat
; pcwzPeerName : LPCWSTR -> "sptr"
; pcwzCloudName : LPCWSTR optional -> "sptr"
; cMaxEndpoints : DWORD optional -> "sptr"
; hEvent : HANDLE -> "sptr"
; phResolve : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "P2P.dll"
#cfunc global PeerPnrpStartResolve "PeerPnrpStartResolve" wstr, wstr, int, sptr, sptr
; res = PeerPnrpStartResolve(pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve)
; pcwzPeerName : LPCWSTR -> "wstr"
; pcwzCloudName : LPCWSTR optional -> "wstr"
; cMaxEndpoints : DWORD optional -> "int"
; hEvent : HANDLE -> "sptr"
; phResolve : void** out -> "sptr"
; HRESULT PeerPnrpStartResolve(LPCWSTR pcwzPeerName, LPCWSTR pcwzCloudName, DWORD cMaxEndpoints, HANDLE hEvent, void** phResolve)
#uselib "P2P.dll"
#cfunc global PeerPnrpStartResolve "PeerPnrpStartResolve" wstr, wstr, int, intptr, intptr
; res = PeerPnrpStartResolve(pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve)
; pcwzPeerName : LPCWSTR -> "wstr"
; pcwzCloudName : LPCWSTR optional -> "wstr"
; cMaxEndpoints : DWORD optional -> "int"
; hEvent : HANDLE -> "intptr"
; phResolve : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerPnrpStartResolve = p2p.NewProc("PeerPnrpStartResolve")
)

// pcwzPeerName (LPCWSTR), pcwzCloudName (LPCWSTR optional), cMaxEndpoints (DWORD optional), hEvent (HANDLE), phResolve (void** out)
r1, _, err := procPeerPnrpStartResolve.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcwzPeerName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcwzCloudName))),
	uintptr(cMaxEndpoints),
	uintptr(hEvent),
	uintptr(phResolve),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function PeerPnrpStartResolve(
  pcwzPeerName: PWideChar;   // LPCWSTR
  pcwzCloudName: PWideChar;   // LPCWSTR optional
  cMaxEndpoints: DWORD;   // DWORD optional
  hEvent: THandle;   // HANDLE
  phResolve: Pointer   // void** out
): Integer; stdcall;
  external 'P2P.dll' name 'PeerPnrpStartResolve';
result := DllCall("P2P\PeerPnrpStartResolve"
    , "WStr", pcwzPeerName   ; LPCWSTR
    , "WStr", pcwzCloudName   ; LPCWSTR optional
    , "UInt", cMaxEndpoints   ; DWORD optional
    , "Ptr", hEvent   ; HANDLE
    , "Ptr", phResolve   ; void** out
    , "Int")   ; return: HRESULT
●PeerPnrpStartResolve(pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve) = DLL("P2P.dll", "int PeerPnrpStartResolve(char*, char*, dword, void*, void*)")
# 呼び出し: PeerPnrpStartResolve(pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve)
# pcwzPeerName : LPCWSTR -> "char*"
# pcwzCloudName : LPCWSTR optional -> "char*"
# cMaxEndpoints : DWORD optional -> "dword"
# hEvent : HANDLE -> "void*"
# phResolve : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "p2p" fn PeerPnrpStartResolve(
    pcwzPeerName: [*c]const u16, // LPCWSTR
    pcwzCloudName: [*c]const u16, // LPCWSTR optional
    cMaxEndpoints: u32, // DWORD optional
    hEvent: ?*anyopaque, // HANDLE
    phResolve: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;
proc PeerPnrpStartResolve(
    pcwzPeerName: WideCString,  # LPCWSTR
    pcwzCloudName: WideCString,  # LPCWSTR optional
    cMaxEndpoints: uint32,  # DWORD optional
    hEvent: pointer,  # HANDLE
    phResolve: pointer  # void** out
): int32 {.importc: "PeerPnrpStartResolve", stdcall, dynlib: "P2P.dll".}
pragma(lib, "p2p");
extern(Windows)
int PeerPnrpStartResolve(
    const(wchar)* pcwzPeerName,   // LPCWSTR
    const(wchar)* pcwzCloudName,   // LPCWSTR optional
    uint cMaxEndpoints,   // DWORD optional
    void* hEvent,   // HANDLE
    void** phResolve   // void** out
);
ccall((:PeerPnrpStartResolve, "P2P.dll"), stdcall, Int32,
      (Cwstring, Cwstring, UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
      pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve)
# pcwzPeerName : LPCWSTR -> Cwstring
# pcwzCloudName : LPCWSTR optional -> Cwstring
# cMaxEndpoints : DWORD optional -> UInt32
# hEvent : HANDLE -> Ptr{Cvoid}
# phResolve : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t PeerPnrpStartResolve(
    const uint16_t* pcwzPeerName,
    const uint16_t* pcwzCloudName,
    uint32_t cMaxEndpoints,
    void* hEvent,
    void** phResolve);
]]
local p2p = ffi.load("p2p")
-- p2p.PeerPnrpStartResolve(pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve)
-- pcwzPeerName : LPCWSTR
-- pcwzCloudName : LPCWSTR optional
-- cMaxEndpoints : DWORD optional
-- hEvent : HANDLE
-- phResolve : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('P2P.dll');
const PeerPnrpStartResolve = lib.func('__stdcall', 'PeerPnrpStartResolve', 'int32_t', ['str16', 'str16', 'uint32_t', 'void *', 'void *']);
// PeerPnrpStartResolve(pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve)
// pcwzPeerName : LPCWSTR -> 'str16'
// pcwzCloudName : LPCWSTR optional -> 'str16'
// cMaxEndpoints : DWORD optional -> 'uint32_t'
// hEvent : HANDLE -> 'void *'
// phResolve : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("P2P.dll", {
  PeerPnrpStartResolve: { parameters: ["buffer", "buffer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.PeerPnrpStartResolve(pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve)
// pcwzPeerName : LPCWSTR -> "buffer"
// pcwzCloudName : LPCWSTR optional -> "buffer"
// cMaxEndpoints : DWORD optional -> "u32"
// hEvent : HANDLE -> "pointer"
// phResolve : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t PeerPnrpStartResolve(
    const uint16_t* pcwzPeerName,
    const uint16_t* pcwzCloudName,
    uint32_t cMaxEndpoints,
    void* hEvent,
    void** phResolve);
C, "P2P.dll");
// $ffi->PeerPnrpStartResolve(pcwzPeerName, pcwzCloudName, cMaxEndpoints, hEvent, phResolve);
// pcwzPeerName : LPCWSTR
// pcwzCloudName : LPCWSTR optional
// cMaxEndpoints : DWORD optional
// hEvent : HANDLE
// phResolve : void** out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface P2p extends StdCallLibrary {
    P2p INSTANCE = Native.load("p2p", P2p.class);
    int PeerPnrpStartResolve(
        WString pcwzPeerName,   // LPCWSTR
        WString pcwzCloudName,   // LPCWSTR optional
        int cMaxEndpoints,   // DWORD optional
        Pointer hEvent,   // HANDLE
        Pointer phResolve   // void** out
    );
}
@[Link("p2p")]
lib LibP2P
  fun PeerPnrpStartResolve = PeerPnrpStartResolve(
    pcwzPeerName : UInt16*,   # LPCWSTR
    pcwzCloudName : UInt16*,   # LPCWSTR optional
    cMaxEndpoints : UInt32,   # DWORD optional
    hEvent : Void*,   # HANDLE
    phResolve : Void**   # void** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef PeerPnrpStartResolveNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Void>, Pointer<Void>);
typedef PeerPnrpStartResolveDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Void>, Pointer<Void>);
final PeerPnrpStartResolve = DynamicLibrary.open('P2P.dll')
    .lookupFunction<PeerPnrpStartResolveNative, PeerPnrpStartResolveDart>('PeerPnrpStartResolve');
// pcwzPeerName : LPCWSTR -> Pointer<Utf16>
// pcwzCloudName : LPCWSTR optional -> Pointer<Utf16>
// cMaxEndpoints : DWORD optional -> Uint32
// hEvent : HANDLE -> Pointer<Void>
// phResolve : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PeerPnrpStartResolve(
  pcwzPeerName: PWideChar;   // LPCWSTR
  pcwzCloudName: PWideChar;   // LPCWSTR optional
  cMaxEndpoints: DWORD;   // DWORD optional
  hEvent: THandle;   // HANDLE
  phResolve: Pointer   // void** out
): Integer; stdcall;
  external 'P2P.dll' name 'PeerPnrpStartResolve';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PeerPnrpStartResolve"
  c_PeerPnrpStartResolve :: CWString -> CWString -> Word32 -> Ptr () -> Ptr () -> IO Int32
-- pcwzPeerName : LPCWSTR -> CWString
-- pcwzCloudName : LPCWSTR optional -> CWString
-- cMaxEndpoints : DWORD optional -> Word32
-- hEvent : HANDLE -> Ptr ()
-- phResolve : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let peerpnrpstartresolve =
  foreign "PeerPnrpStartResolve"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pcwzPeerName : LPCWSTR -> (ptr uint16_t) *)
(* pcwzCloudName : LPCWSTR optional -> (ptr uint16_t) *)
(* cMaxEndpoints : DWORD optional -> uint32_t *)
(* hEvent : HANDLE -> (ptr void) *)
(* phResolve : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library p2p (t "P2P.dll"))
(cffi:use-foreign-library p2p)

(cffi:defcfun ("PeerPnrpStartResolve" peer-pnrp-start-resolve :convention :stdcall) :int32
  (pcwz-peer-name (:string :encoding :utf-16le))   ; LPCWSTR
  (pcwz-cloud-name (:string :encoding :utf-16le))   ; LPCWSTR optional
  (c-max-endpoints :uint32)   ; DWORD optional
  (h-event :pointer)   ; HANDLE
  (ph-resolve :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PeerPnrpStartResolve = Win32::API::More->new('P2P',
    'int PeerPnrpStartResolve(LPCWSTR pcwzPeerName, LPCWSTR pcwzCloudName, DWORD cMaxEndpoints, HANDLE hEvent, LPVOID phResolve)');
# my $ret = $PeerPnrpStartResolve->Call($pcwzPeerName, $pcwzCloudName, $cMaxEndpoints, $hEvent, $phResolve);
# pcwzPeerName : LPCWSTR -> LPCWSTR
# pcwzCloudName : LPCWSTR optional -> LPCWSTR
# cMaxEndpoints : DWORD optional -> DWORD
# hEvent : HANDLE -> HANDLE
# phResolve : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。