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

PeerGraphImportDatabase

関数
ファイルからピアグラフのデータベースをインポートする。
DLLP2PGRAPH.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT PeerGraphImportDatabase(
    void* hGraph,
    LPCWSTR pwzFilePath
);

パラメーター

名前方向説明
hGraphvoid*inデータベースをインポートする対象のグラフを表すハンドル。
pwzFilePathLPCWSTRinインポート元のファイルパスを示すUnicode文字列へのポインター。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

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

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

var (
	p2pgraph = windows.NewLazySystemDLL("P2PGRAPH.dll")
	procPeerGraphImportDatabase = p2pgraph.NewProc("PeerGraphImportDatabase")
)

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

extern "p2pgraph" fn PeerGraphImportDatabase(
    hGraph: ?*anyopaque, // void*
    pwzFilePath: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;
proc PeerGraphImportDatabase(
    hGraph: pointer,  # void*
    pwzFilePath: WideCString  # LPCWSTR
): int32 {.importc: "PeerGraphImportDatabase", stdcall, dynlib: "P2PGRAPH.dll".}
pragma(lib, "p2pgraph");
extern(Windows)
int PeerGraphImportDatabase(
    void* hGraph,   // void*
    const(wchar)* pwzFilePath   // LPCWSTR
);
ccall((:PeerGraphImportDatabase, "P2PGRAPH.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cwstring),
      hGraph, pwzFilePath)
# hGraph : void* -> Ptr{Cvoid}
# pwzFilePath : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t PeerGraphImportDatabase(
    void* hGraph,
    const uint16_t* pwzFilePath);
]]
local p2pgraph = ffi.load("p2pgraph")
-- p2pgraph.PeerGraphImportDatabase(hGraph, pwzFilePath)
-- hGraph : void*
-- pwzFilePath : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('P2PGRAPH.dll');
const PeerGraphImportDatabase = lib.func('__stdcall', 'PeerGraphImportDatabase', 'int32_t', ['void *', 'str16']);
// PeerGraphImportDatabase(hGraph, pwzFilePath)
// hGraph : void* -> 'void *'
// pwzFilePath : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("P2PGRAPH.dll", {
  PeerGraphImportDatabase: { parameters: ["pointer", "buffer"], result: "i32" },
});
// lib.symbols.PeerGraphImportDatabase(hGraph, pwzFilePath)
// hGraph : void* -> "pointer"
// pwzFilePath : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t PeerGraphImportDatabase(
    void* hGraph,
    const uint16_t* pwzFilePath);
C, "P2PGRAPH.dll");
// $ffi->PeerGraphImportDatabase(hGraph, pwzFilePath);
// hGraph : void*
// pwzFilePath : 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 PeerGraphImportDatabase(
        Pointer hGraph,   // void*
        WString pwzFilePath   // LPCWSTR
    );
}
@[Link("p2pgraph")]
lib LibP2PGRAPH
  fun PeerGraphImportDatabase = PeerGraphImportDatabase(
    hGraph : Void*,   # void*
    pwzFilePath : 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 PeerGraphImportDatabaseNative = Int32 Function(Pointer<Void>, Pointer<Utf16>);
typedef PeerGraphImportDatabaseDart = int Function(Pointer<Void>, Pointer<Utf16>);
final PeerGraphImportDatabase = DynamicLibrary.open('P2PGRAPH.dll')
    .lookupFunction<PeerGraphImportDatabaseNative, PeerGraphImportDatabaseDart>('PeerGraphImportDatabase');
// hGraph : void* -> Pointer<Void>
// pwzFilePath : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PeerGraphImportDatabase(
  hGraph: Pointer;   // void*
  pwzFilePath: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'P2PGRAPH.dll' name 'PeerGraphImportDatabase';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let peergraphimportdatabase =
  foreign "PeerGraphImportDatabase"
    ((ptr void) @-> (ptr uint16_t) @-> returning int32_t)
(* hGraph : void* -> (ptr void) *)
(* pwzFilePath : 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 ("PeerGraphImportDatabase" peer-graph-import-database :convention :stdcall) :int32
  (h-graph :pointer)   ; void*
  (pwz-file-path (:string :encoding :utf-16le)))   ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PeerGraphImportDatabase = Win32::API::More->new('P2PGRAPH',
    'int PeerGraphImportDatabase(LPVOID hGraph, LPCWSTR pwzFilePath)');
# my $ret = $PeerGraphImportDatabase->Call($hGraph, $pwzFilePath);
# hGraph : void* -> LPVOID
# pwzFilePath : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。