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