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

PeerGraphSetPresence

関数
ピアグラフ内の自ノードのプレゼンス状態を設定する。
DLLP2PGRAPH.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerGraphSetPresence(
    void* hGraph,
    BOOL fPresent
);

パラメーター

名前方向説明
hGraphvoid*inプレゼンスを設定する対象のグラフを表すハンドル。
fPresentBOOLinTRUEでオンライン(在席)、FALSEでオフラインを示す在席状態の真偽値。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PeerGraphSetPresence(
    void* hGraph,
    BOOL fPresent
);
[DllImport("P2PGRAPH.dll", ExactSpelling = true)]
static extern int PeerGraphSetPresence(
    IntPtr hGraph,   // void*
    bool fPresent   // BOOL
);
<DllImport("P2PGRAPH.dll", ExactSpelling:=True)>
Public Shared Function PeerGraphSetPresence(
    hGraph As IntPtr,   ' void*
    fPresent As Boolean   ' BOOL
) As Integer
End Function
' hGraph : void*
' fPresent : BOOL
Declare PtrSafe Function PeerGraphSetPresence Lib "p2pgraph" ( _
    ByVal hGraph As LongPtr, _
    ByVal fPresent As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PeerGraphSetPresence = ctypes.windll.p2pgraph.PeerGraphSetPresence
PeerGraphSetPresence.restype = ctypes.c_int
PeerGraphSetPresence.argtypes = [
    ctypes.POINTER(None),  # hGraph : void*
    wintypes.BOOL,  # fPresent : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('P2PGRAPH.dll')
PeerGraphSetPresence = Fiddle::Function.new(
  lib['PeerGraphSetPresence'],
  [
    Fiddle::TYPE_VOIDP,  # hGraph : void*
    Fiddle::TYPE_INT,  # fPresent : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "p2pgraph")]
extern "system" {
    fn PeerGraphSetPresence(
        hGraph: *mut (),  // void*
        fPresent: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("P2PGRAPH.dll")]
public static extern int PeerGraphSetPresence(IntPtr hGraph, bool fPresent);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2PGRAPH_PeerGraphSetPresence' -Namespace Win32 -PassThru
# $api::PeerGraphSetPresence(hGraph, fPresent)
#uselib "P2PGRAPH.dll"
#func global PeerGraphSetPresence "PeerGraphSetPresence" sptr, sptr
; PeerGraphSetPresence hGraph, fPresent   ; 戻り値は stat
; hGraph : void* -> "sptr"
; fPresent : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "P2PGRAPH.dll"
#cfunc global PeerGraphSetPresence "PeerGraphSetPresence" sptr, int
; res = PeerGraphSetPresence(hGraph, fPresent)
; hGraph : void* -> "sptr"
; fPresent : BOOL -> "int"
; HRESULT PeerGraphSetPresence(void* hGraph, BOOL fPresent)
#uselib "P2PGRAPH.dll"
#cfunc global PeerGraphSetPresence "PeerGraphSetPresence" intptr, int
; res = PeerGraphSetPresence(hGraph, fPresent)
; hGraph : void* -> "intptr"
; fPresent : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	p2pgraph = windows.NewLazySystemDLL("P2PGRAPH.dll")
	procPeerGraphSetPresence = p2pgraph.NewProc("PeerGraphSetPresence")
)

// hGraph (void*), fPresent (BOOL)
r1, _, err := procPeerGraphSetPresence.Call(
	uintptr(hGraph),
	uintptr(fPresent),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function PeerGraphSetPresence(
  hGraph: Pointer;   // void*
  fPresent: BOOL   // BOOL
): Integer; stdcall;
  external 'P2PGRAPH.dll' name 'PeerGraphSetPresence';
result := DllCall("P2PGRAPH\PeerGraphSetPresence"
    , "Ptr", hGraph   ; void*
    , "Int", fPresent   ; BOOL
    , "Int")   ; return: HRESULT
●PeerGraphSetPresence(hGraph, fPresent) = DLL("P2PGRAPH.dll", "int PeerGraphSetPresence(void*, bool)")
# 呼び出し: PeerGraphSetPresence(hGraph, fPresent)
# hGraph : void* -> "void*"
# fPresent : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "p2pgraph" fn PeerGraphSetPresence(
    hGraph: ?*anyopaque, // void*
    fPresent: i32 // BOOL
) callconv(std.os.windows.WINAPI) i32;
proc PeerGraphSetPresence(
    hGraph: pointer,  # void*
    fPresent: int32  # BOOL
): int32 {.importc: "PeerGraphSetPresence", stdcall, dynlib: "P2PGRAPH.dll".}
pragma(lib, "p2pgraph");
extern(Windows)
int PeerGraphSetPresence(
    void* hGraph,   // void*
    int fPresent   // BOOL
);
ccall((:PeerGraphSetPresence, "P2PGRAPH.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Int32),
      hGraph, fPresent)
# hGraph : void* -> Ptr{Cvoid}
# fPresent : BOOL -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t PeerGraphSetPresence(
    void* hGraph,
    int32_t fPresent);
]]
local p2pgraph = ffi.load("p2pgraph")
-- p2pgraph.PeerGraphSetPresence(hGraph, fPresent)
-- hGraph : void*
-- fPresent : BOOL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('P2PGRAPH.dll');
const PeerGraphSetPresence = lib.func('__stdcall', 'PeerGraphSetPresence', 'int32_t', ['void *', 'int32_t']);
// PeerGraphSetPresence(hGraph, fPresent)
// hGraph : void* -> 'void *'
// fPresent : BOOL -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("P2PGRAPH.dll", {
  PeerGraphSetPresence: { parameters: ["pointer", "i32"], result: "i32" },
});
// lib.symbols.PeerGraphSetPresence(hGraph, fPresent)
// hGraph : void* -> "pointer"
// fPresent : BOOL -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t PeerGraphSetPresence(
    void* hGraph,
    int32_t fPresent);
C, "P2PGRAPH.dll");
// $ffi->PeerGraphSetPresence(hGraph, fPresent);
// hGraph : void*
// fPresent : BOOL
// 構造体/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 PeerGraphSetPresence(
        Pointer hGraph,   // void*
        boolean fPresent   // BOOL
    );
}
@[Link("p2pgraph")]
lib LibP2PGRAPH
  fun PeerGraphSetPresence = PeerGraphSetPresence(
    hGraph : Void*,   # void*
    fPresent : Int32   # BOOL
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef PeerGraphSetPresenceNative = Int32 Function(Pointer<Void>, Int32);
typedef PeerGraphSetPresenceDart = int Function(Pointer<Void>, int);
final PeerGraphSetPresence = DynamicLibrary.open('P2PGRAPH.dll')
    .lookupFunction<PeerGraphSetPresenceNative, PeerGraphSetPresenceDart>('PeerGraphSetPresence');
// hGraph : void* -> Pointer<Void>
// fPresent : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PeerGraphSetPresence(
  hGraph: Pointer;   // void*
  fPresent: BOOL   // BOOL
): Integer; stdcall;
  external 'P2PGRAPH.dll' name 'PeerGraphSetPresence';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PeerGraphSetPresence"
  c_PeerGraphSetPresence :: Ptr () -> CInt -> IO Int32
-- hGraph : void* -> Ptr ()
-- fPresent : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let peergraphsetpresence =
  foreign "PeerGraphSetPresence"
    ((ptr void) @-> int32_t @-> returning int32_t)
(* hGraph : void* -> (ptr void) *)
(* fPresent : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library p2pgraph (t "P2PGRAPH.dll"))
(cffi:use-foreign-library p2pgraph)

(cffi:defcfun ("PeerGraphSetPresence" peer-graph-set-presence :convention :stdcall) :int32
  (h-graph :pointer)   ; void*
  (f-present :int32))   ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PeerGraphSetPresence = Win32::API::More->new('P2PGRAPH',
    'int PeerGraphSetPresence(LPVOID hGraph, BOOL fPresent)');
# my $ret = $PeerGraphSetPresence->Call($hGraph, $fPresent);
# hGraph : void* -> LPVOID
# fPresent : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。