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