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