ホーム › NetworkManagement.P2P › PeerGroupPasswordJoin
PeerGroupPasswordJoin
関数パスワード認証の招待を使ってピアグループに参加する。
シグネチャ
// P2P.dll
#include <windows.h>
HRESULT PeerGroupPasswordJoin(
LPCWSTR pwzIdentity,
LPCWSTR pwzInvitation,
LPCWSTR pwzPassword,
LPCWSTR pwzCloud, // optional
void** phGroup
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pwzIdentity | LPCWSTR | in | グループに参加するピアの識別子を示すUnicode文字列へのポインター。 |
| pwzInvitation | LPCWSTR | in | パスワード認証用の招待状を示すUnicode文字列へのポインター。 |
| pwzPassword | LPCWSTR | in | 参加に必要なパスワードを示すUnicode文字列へのポインター。 |
| pwzCloud | LPCWSTR | inoptional | グループが存在するクラウド(スコープ)名を示す文字列。NULL可。 |
| phGroup | void** | out | 参加したグループのハンドルを受け取る出力ポインター。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// P2P.dll
#include <windows.h>
HRESULT PeerGroupPasswordJoin(
LPCWSTR pwzIdentity,
LPCWSTR pwzInvitation,
LPCWSTR pwzPassword,
LPCWSTR pwzCloud, // optional
void** phGroup
);[DllImport("P2P.dll", ExactSpelling = true)]
static extern int PeerGroupPasswordJoin(
[MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pwzInvitation, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pwzPassword, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pwzCloud, // LPCWSTR optional
IntPtr phGroup // void** out
);<DllImport("P2P.dll", ExactSpelling:=True)>
Public Shared Function PeerGroupPasswordJoin(
<MarshalAs(UnmanagedType.LPWStr)> pwzIdentity As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pwzInvitation As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pwzPassword As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pwzCloud As String, ' LPCWSTR optional
phGroup As IntPtr ' void** out
) As Integer
End Function' pwzIdentity : LPCWSTR
' pwzInvitation : LPCWSTR
' pwzPassword : LPCWSTR
' pwzCloud : LPCWSTR optional
' phGroup : void** out
Declare PtrSafe Function PeerGroupPasswordJoin Lib "p2p" ( _
ByVal pwzIdentity As LongPtr, _
ByVal pwzInvitation As LongPtr, _
ByVal pwzPassword 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
PeerGroupPasswordJoin = ctypes.windll.p2p.PeerGroupPasswordJoin
PeerGroupPasswordJoin.restype = ctypes.c_int
PeerGroupPasswordJoin.argtypes = [
wintypes.LPCWSTR, # pwzIdentity : LPCWSTR
wintypes.LPCWSTR, # pwzInvitation : LPCWSTR
wintypes.LPCWSTR, # pwzPassword : LPCWSTR
wintypes.LPCWSTR, # pwzCloud : LPCWSTR optional
ctypes.c_void_p, # phGroup : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('P2P.dll')
PeerGroupPasswordJoin = Fiddle::Function.new(
lib['PeerGroupPasswordJoin'],
[
Fiddle::TYPE_VOIDP, # pwzIdentity : LPCWSTR
Fiddle::TYPE_VOIDP, # pwzInvitation : LPCWSTR
Fiddle::TYPE_VOIDP, # pwzPassword : LPCWSTR
Fiddle::TYPE_VOIDP, # pwzCloud : LPCWSTR optional
Fiddle::TYPE_VOIDP, # phGroup : void** out
],
Fiddle::TYPE_INT)#[link(name = "p2p")]
extern "system" {
fn PeerGroupPasswordJoin(
pwzIdentity: *const u16, // LPCWSTR
pwzInvitation: *const u16, // LPCWSTR
pwzPassword: *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 PeerGroupPasswordJoin([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, [MarshalAs(UnmanagedType.LPWStr)] string pwzInvitation, [MarshalAs(UnmanagedType.LPWStr)] string pwzPassword, [MarshalAs(UnmanagedType.LPWStr)] string pwzCloud, IntPtr phGroup);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2P_PeerGroupPasswordJoin' -Namespace Win32 -PassThru
# $api::PeerGroupPasswordJoin(pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup)#uselib "P2P.dll"
#func global PeerGroupPasswordJoin "PeerGroupPasswordJoin" sptr, sptr, sptr, sptr, sptr
; PeerGroupPasswordJoin pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup ; 戻り値は stat
; pwzIdentity : LPCWSTR -> "sptr"
; pwzInvitation : LPCWSTR -> "sptr"
; pwzPassword : LPCWSTR -> "sptr"
; pwzCloud : LPCWSTR optional -> "sptr"
; phGroup : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "P2P.dll"
#cfunc global PeerGroupPasswordJoin "PeerGroupPasswordJoin" wstr, wstr, wstr, wstr, sptr
; res = PeerGroupPasswordJoin(pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup)
; pwzIdentity : LPCWSTR -> "wstr"
; pwzInvitation : LPCWSTR -> "wstr"
; pwzPassword : LPCWSTR -> "wstr"
; pwzCloud : LPCWSTR optional -> "wstr"
; phGroup : void** out -> "sptr"; HRESULT PeerGroupPasswordJoin(LPCWSTR pwzIdentity, LPCWSTR pwzInvitation, LPCWSTR pwzPassword, LPCWSTR pwzCloud, void** phGroup)
#uselib "P2P.dll"
#cfunc global PeerGroupPasswordJoin "PeerGroupPasswordJoin" wstr, wstr, wstr, wstr, intptr
; res = PeerGroupPasswordJoin(pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup)
; pwzIdentity : LPCWSTR -> "wstr"
; pwzInvitation : LPCWSTR -> "wstr"
; pwzPassword : LPCWSTR -> "wstr"
; pwzCloud : LPCWSTR optional -> "wstr"
; phGroup : void** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
p2p = windows.NewLazySystemDLL("P2P.dll")
procPeerGroupPasswordJoin = p2p.NewProc("PeerGroupPasswordJoin")
)
// pwzIdentity (LPCWSTR), pwzInvitation (LPCWSTR), pwzPassword (LPCWSTR), pwzCloud (LPCWSTR optional), phGroup (void** out)
r1, _, err := procPeerGroupPasswordJoin.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzIdentity))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzInvitation))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzPassword))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzCloud))),
uintptr(phGroup),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction PeerGroupPasswordJoin(
pwzIdentity: PWideChar; // LPCWSTR
pwzInvitation: PWideChar; // LPCWSTR
pwzPassword: PWideChar; // LPCWSTR
pwzCloud: PWideChar; // LPCWSTR optional
phGroup: Pointer // void** out
): Integer; stdcall;
external 'P2P.dll' name 'PeerGroupPasswordJoin';result := DllCall("P2P\PeerGroupPasswordJoin"
, "WStr", pwzIdentity ; LPCWSTR
, "WStr", pwzInvitation ; LPCWSTR
, "WStr", pwzPassword ; LPCWSTR
, "WStr", pwzCloud ; LPCWSTR optional
, "Ptr", phGroup ; void** out
, "Int") ; return: HRESULT●PeerGroupPasswordJoin(pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup) = DLL("P2P.dll", "int PeerGroupPasswordJoin(char*, char*, char*, char*, void*)")
# 呼び出し: PeerGroupPasswordJoin(pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup)
# pwzIdentity : LPCWSTR -> "char*"
# pwzInvitation : LPCWSTR -> "char*"
# pwzPassword : LPCWSTR -> "char*"
# pwzCloud : LPCWSTR optional -> "char*"
# phGroup : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "p2p" fn PeerGroupPasswordJoin(
pwzIdentity: [*c]const u16, // LPCWSTR
pwzInvitation: [*c]const u16, // LPCWSTR
pwzPassword: [*c]const u16, // LPCWSTR
pwzCloud: [*c]const u16, // LPCWSTR optional
phGroup: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc PeerGroupPasswordJoin(
pwzIdentity: WideCString, # LPCWSTR
pwzInvitation: WideCString, # LPCWSTR
pwzPassword: WideCString, # LPCWSTR
pwzCloud: WideCString, # LPCWSTR optional
phGroup: pointer # void** out
): int32 {.importc: "PeerGroupPasswordJoin", stdcall, dynlib: "P2P.dll".}pragma(lib, "p2p");
extern(Windows)
int PeerGroupPasswordJoin(
const(wchar)* pwzIdentity, // LPCWSTR
const(wchar)* pwzInvitation, // LPCWSTR
const(wchar)* pwzPassword, // LPCWSTR
const(wchar)* pwzCloud, // LPCWSTR optional
void** phGroup // void** out
);ccall((:PeerGroupPasswordJoin, "P2P.dll"), stdcall, Int32,
(Cwstring, Cwstring, Cwstring, Cwstring, Ptr{Cvoid}),
pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup)
# pwzIdentity : LPCWSTR -> Cwstring
# pwzInvitation : LPCWSTR -> Cwstring
# pwzPassword : LPCWSTR -> Cwstring
# pwzCloud : LPCWSTR optional -> Cwstring
# phGroup : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t PeerGroupPasswordJoin(
const uint16_t* pwzIdentity,
const uint16_t* pwzInvitation,
const uint16_t* pwzPassword,
const uint16_t* pwzCloud,
void** phGroup);
]]
local p2p = ffi.load("p2p")
-- p2p.PeerGroupPasswordJoin(pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup)
-- pwzIdentity : LPCWSTR
-- pwzInvitation : LPCWSTR
-- pwzPassword : LPCWSTR
-- pwzCloud : LPCWSTR optional
-- phGroup : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('P2P.dll');
const PeerGroupPasswordJoin = lib.func('__stdcall', 'PeerGroupPasswordJoin', 'int32_t', ['str16', 'str16', 'str16', 'str16', 'void *']);
// PeerGroupPasswordJoin(pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup)
// pwzIdentity : LPCWSTR -> 'str16'
// pwzInvitation : LPCWSTR -> 'str16'
// pwzPassword : LPCWSTR -> 'str16'
// pwzCloud : LPCWSTR optional -> 'str16'
// phGroup : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("P2P.dll", {
PeerGroupPasswordJoin: { parameters: ["buffer", "buffer", "buffer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.PeerGroupPasswordJoin(pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup)
// pwzIdentity : LPCWSTR -> "buffer"
// pwzInvitation : LPCWSTR -> "buffer"
// pwzPassword : LPCWSTR -> "buffer"
// pwzCloud : LPCWSTR optional -> "buffer"
// phGroup : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t PeerGroupPasswordJoin(
const uint16_t* pwzIdentity,
const uint16_t* pwzInvitation,
const uint16_t* pwzPassword,
const uint16_t* pwzCloud,
void** phGroup);
C, "P2P.dll");
// $ffi->PeerGroupPasswordJoin(pwzIdentity, pwzInvitation, pwzPassword, pwzCloud, phGroup);
// pwzIdentity : LPCWSTR
// pwzInvitation : LPCWSTR
// pwzPassword : LPCWSTR
// pwzCloud : LPCWSTR optional
// phGroup : 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 PeerGroupPasswordJoin(
WString pwzIdentity, // LPCWSTR
WString pwzInvitation, // LPCWSTR
WString pwzPassword, // LPCWSTR
WString pwzCloud, // LPCWSTR optional
Pointer phGroup // void** out
);
}@[Link("p2p")]
lib LibP2P
fun PeerGroupPasswordJoin = PeerGroupPasswordJoin(
pwzIdentity : UInt16*, # LPCWSTR
pwzInvitation : UInt16*, # LPCWSTR
pwzPassword : UInt16*, # LPCWSTR
pwzCloud : UInt16*, # LPCWSTR optional
phGroup : 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 PeerGroupPasswordJoinNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
typedef PeerGroupPasswordJoinDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
final PeerGroupPasswordJoin = DynamicLibrary.open('P2P.dll')
.lookupFunction<PeerGroupPasswordJoinNative, PeerGroupPasswordJoinDart>('PeerGroupPasswordJoin');
// pwzIdentity : LPCWSTR -> Pointer<Utf16>
// pwzInvitation : LPCWSTR -> Pointer<Utf16>
// pwzPassword : LPCWSTR -> Pointer<Utf16>
// pwzCloud : LPCWSTR optional -> Pointer<Utf16>
// phGroup : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PeerGroupPasswordJoin(
pwzIdentity: PWideChar; // LPCWSTR
pwzInvitation: PWideChar; // LPCWSTR
pwzPassword: PWideChar; // LPCWSTR
pwzCloud: PWideChar; // LPCWSTR optional
phGroup: Pointer // void** out
): Integer; stdcall;
external 'P2P.dll' name 'PeerGroupPasswordJoin';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PeerGroupPasswordJoin"
c_PeerGroupPasswordJoin :: CWString -> CWString -> CWString -> CWString -> Ptr () -> IO Int32
-- pwzIdentity : LPCWSTR -> CWString
-- pwzInvitation : LPCWSTR -> CWString
-- pwzPassword : LPCWSTR -> CWString
-- pwzCloud : LPCWSTR optional -> CWString
-- phGroup : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let peergrouppasswordjoin =
foreign "PeerGroupPasswordJoin"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* pwzIdentity : LPCWSTR -> (ptr uint16_t) *)
(* pwzInvitation : LPCWSTR -> (ptr uint16_t) *)
(* pwzPassword : LPCWSTR -> (ptr uint16_t) *)
(* pwzCloud : LPCWSTR optional -> (ptr uint16_t) *)
(* phGroup : 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 ("PeerGroupPasswordJoin" peer-group-password-join :convention :stdcall) :int32
(pwz-identity (:string :encoding :utf-16le)) ; LPCWSTR
(pwz-invitation (:string :encoding :utf-16le)) ; LPCWSTR
(pwz-password (:string :encoding :utf-16le)) ; LPCWSTR
(pwz-cloud (:string :encoding :utf-16le)) ; LPCWSTR optional
(ph-group :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PeerGroupPasswordJoin = Win32::API::More->new('P2P',
'int PeerGroupPasswordJoin(LPCWSTR pwzIdentity, LPCWSTR pwzInvitation, LPCWSTR pwzPassword, LPCWSTR pwzCloud, LPVOID phGroup)');
# my $ret = $PeerGroupPasswordJoin->Call($pwzIdentity, $pwzInvitation, $pwzPassword, $pwzCloud, $phGroup);
# pwzIdentity : LPCWSTR -> LPCWSTR
# pwzInvitation : LPCWSTR -> LPCWSTR
# pwzPassword : LPCWSTR -> LPCWSTR
# pwzCloud : LPCWSTR optional -> LPCWSTR
# phGroup : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。