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

PeerPnrpRegister

関数
ピア名をPNRPクラウドに登録する。
DLLP2P.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerPnrpRegister(
    LPCWSTR pcwzPeerName,
    PEER_PNRP_REGISTRATION_INFO* pRegistrationInfo,   // optional
    void** phRegistration
);

パラメーター

名前方向
pcwzPeerNameLPCWSTRin
pRegistrationInfoPEER_PNRP_REGISTRATION_INFO*inoptional
phRegistrationvoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

PeerPnrpRegister = ctypes.windll.p2p.PeerPnrpRegister
PeerPnrpRegister.restype = ctypes.c_int
PeerPnrpRegister.argtypes = [
    wintypes.LPCWSTR,  # pcwzPeerName : LPCWSTR
    ctypes.c_void_p,  # pRegistrationInfo : PEER_PNRP_REGISTRATION_INFO* optional
    ctypes.c_void_p,  # phRegistration : void** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerPnrpRegister = p2p.NewProc("PeerPnrpRegister")
)

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