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

PeerCollabSignin

関数
ピアコラボレーションのプレゼンスにサインインする。
DLLP2P.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT PeerCollabSignin(
    HWND hwndParent,   // optional
    DWORD dwSigninOptions
);

パラメーター

名前方向説明
hwndParentHWNDinoptionalサインインUIの親となるウィンドウのハンドル。NULL可。
dwSigninOptionsDWORDinサインイン範囲を指定するフラグ(PEER_SIGNIN_NEAR_ME/INTERNET等)。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PeerCollabSignin(
    HWND hwndParent,   // optional
    DWORD dwSigninOptions
);
[DllImport("P2P.dll", ExactSpelling = true)]
static extern int PeerCollabSignin(
    IntPtr hwndParent,   // HWND optional
    uint dwSigninOptions   // DWORD
);
<DllImport("P2P.dll", ExactSpelling:=True)>
Public Shared Function PeerCollabSignin(
    hwndParent As IntPtr,   ' HWND optional
    dwSigninOptions As UInteger   ' DWORD
) As Integer
End Function
' hwndParent : HWND optional
' dwSigninOptions : DWORD
Declare PtrSafe Function PeerCollabSignin Lib "p2p" ( _
    ByVal hwndParent As LongPtr, _
    ByVal dwSigninOptions As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PeerCollabSignin = ctypes.windll.p2p.PeerCollabSignin
PeerCollabSignin.restype = ctypes.c_int
PeerCollabSignin.argtypes = [
    wintypes.HANDLE,  # hwndParent : HWND optional
    wintypes.DWORD,  # dwSigninOptions : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	p2p = windows.NewLazySystemDLL("P2P.dll")
	procPeerCollabSignin = p2p.NewProc("PeerCollabSignin")
)

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

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

typedef PeerCollabSigninNative = Int32 Function(Pointer<Void>, Uint32);
typedef PeerCollabSigninDart = int Function(Pointer<Void>, int);
final PeerCollabSignin = DynamicLibrary.open('P2P.dll')
    .lookupFunction<PeerCollabSigninNative, PeerCollabSigninDart>('PeerCollabSignin');
// hwndParent : HWND optional -> Pointer<Void>
// dwSigninOptions : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PeerCollabSignin(
  hwndParent: THandle;   // HWND optional
  dwSigninOptions: DWORD   // DWORD
): Integer; stdcall;
  external 'P2P.dll' name 'PeerCollabSignin';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PeerCollabSignin"
  c_PeerCollabSignin :: Ptr () -> Word32 -> IO Int32
-- hwndParent : HWND optional -> Ptr ()
-- dwSigninOptions : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let peercollabsignin =
  foreign "PeerCollabSignin"
    ((ptr void) @-> uint32_t @-> returning int32_t)
(* hwndParent : HWND optional -> (ptr void) *)
(* dwSigninOptions : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library p2p (t "P2P.dll"))
(cffi:use-foreign-library p2p)

(cffi:defcfun ("PeerCollabSignin" peer-collab-signin :convention :stdcall) :int32
  (hwnd-parent :pointer)   ; HWND optional
  (dw-signin-options :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PeerCollabSignin = Win32::API::More->new('P2P',
    'int PeerCollabSignin(HANDLE hwndParent, DWORD dwSigninOptions)');
# my $ret = $PeerCollabSignin->Call($hwndParent, $dwSigninOptions);
# hwndParent : HWND optional -> HANDLE
# dwSigninOptions : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。