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

PeerGroupJoin

関数
招待を使用して既存のピアグループに参加する。
DLLP2P.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerGroupJoin(
    LPCWSTR pwzIdentity,
    LPCWSTR pwzInvitation,
    LPCWSTR pwzCloud,   // optional
    void** phGroup
);

パラメーター

名前方向
pwzIdentityLPCWSTRin
pwzInvitationLPCWSTRin
pwzCloudLPCWSTRinoptional
phGroupvoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

PeerGroupJoin = ctypes.windll.p2p.PeerGroupJoin
PeerGroupJoin.restype = ctypes.c_int
PeerGroupJoin.argtypes = [
    wintypes.LPCWSTR,  # pwzIdentity : LPCWSTR
    wintypes.LPCWSTR,  # pwzInvitation : LPCWSTR
    wintypes.LPCWSTR,  # pwzCloud : LPCWSTR optional
    ctypes.c_void_p,  # phGroup : void** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerGroupJoin = p2p.NewProc("PeerGroupJoin")
)

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