ホーム › NetworkManagement.P2P › PeerDistServerOpenContentInformationEx
PeerDistServerOpenContentInformationEx
関数サーバー側でコンテンツの一部範囲のコンテンツ情報を非同期に開く。
シグネチャ
// PeerDist.dll
#include <windows.h>
DWORD PeerDistServerOpenContentInformationEx(
INT_PTR hPeerDist,
DWORD cbContentIdentifier,
BYTE* pContentIdentifier,
ULONGLONG ullContentOffset,
ULONGLONG cbContentLength,
PEERDIST_RETRIEVAL_OPTIONS* pRetrievalOptions,
HANDLE hCompletionPort, // optional
UINT_PTR ulCompletionKey, // optional
INT_PTR* phContentInfo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hPeerDist | INT_PTR | in | 対象のPeerDistセッションのハンドル。 |
| cbContentIdentifier | DWORD | in | pContentIdentifierが指すコンテンツ識別子のバイト数。 |
| pContentIdentifier | BYTE* | in | コンテンツ情報を取得する対象の識別子バイト列へのポインタ。 |
| ullContentOffset | ULONGLONG | in | コンテンツ情報を取得する開始オフセット(バイト)。 |
| cbContentLength | ULONGLONG | in | 情報取得対象とするコンテンツ範囲の長さ(バイト)。 |
| pRetrievalOptions | PEERDIST_RETRIEVAL_OPTIONS* | in | 取得オプション(バージョン等)を格納したPEERDIST_RETRIEVAL_OPTIONS構造体へのポインタ。 |
| hCompletionPort | HANDLE | inoptional | 非同期完了通知を受け取る完了ポートのハンドル。 |
| ulCompletionKey | UINT_PTR | inoptional | 完了パケットに関連付ける完了キー。 |
| phContentInfo | INT_PTR* | out | コンテンツ情報ハンドルを受け取るポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// PeerDist.dll
#include <windows.h>
DWORD PeerDistServerOpenContentInformationEx(
INT_PTR hPeerDist,
DWORD cbContentIdentifier,
BYTE* pContentIdentifier,
ULONGLONG ullContentOffset,
ULONGLONG cbContentLength,
PEERDIST_RETRIEVAL_OPTIONS* pRetrievalOptions,
HANDLE hCompletionPort, // optional
UINT_PTR ulCompletionKey, // optional
INT_PTR* phContentInfo
);[DllImport("PeerDist.dll", ExactSpelling = true)]
static extern uint PeerDistServerOpenContentInformationEx(
IntPtr hPeerDist, // INT_PTR
uint cbContentIdentifier, // DWORD
IntPtr pContentIdentifier, // BYTE*
ulong ullContentOffset, // ULONGLONG
ulong cbContentLength, // ULONGLONG
IntPtr pRetrievalOptions, // PEERDIST_RETRIEVAL_OPTIONS*
IntPtr hCompletionPort, // HANDLE optional
UIntPtr ulCompletionKey, // UINT_PTR optional
out IntPtr phContentInfo // INT_PTR* out
);<DllImport("PeerDist.dll", ExactSpelling:=True)>
Public Shared Function PeerDistServerOpenContentInformationEx(
hPeerDist As IntPtr, ' INT_PTR
cbContentIdentifier As UInteger, ' DWORD
pContentIdentifier As IntPtr, ' BYTE*
ullContentOffset As ULong, ' ULONGLONG
cbContentLength As ULong, ' ULONGLONG
pRetrievalOptions As IntPtr, ' PEERDIST_RETRIEVAL_OPTIONS*
hCompletionPort As IntPtr, ' HANDLE optional
ulCompletionKey As UIntPtr, ' UINT_PTR optional
<Out> ByRef phContentInfo As IntPtr ' INT_PTR* out
) As UInteger
End Function' hPeerDist : INT_PTR
' cbContentIdentifier : DWORD
' pContentIdentifier : BYTE*
' ullContentOffset : ULONGLONG
' cbContentLength : ULONGLONG
' pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS*
' hCompletionPort : HANDLE optional
' ulCompletionKey : UINT_PTR optional
' phContentInfo : INT_PTR* out
Declare PtrSafe Function PeerDistServerOpenContentInformationEx Lib "peerdist" ( _
ByVal hPeerDist As LongPtr, _
ByVal cbContentIdentifier As Long, _
ByVal pContentIdentifier As LongPtr, _
ByVal ullContentOffset As LongLong, _
ByVal cbContentLength As LongLong, _
ByVal pRetrievalOptions As LongPtr, _
ByVal hCompletionPort As LongPtr, _
ByVal ulCompletionKey As LongPtr, _
ByRef phContentInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PeerDistServerOpenContentInformationEx = ctypes.windll.peerdist.PeerDistServerOpenContentInformationEx
PeerDistServerOpenContentInformationEx.restype = wintypes.DWORD
PeerDistServerOpenContentInformationEx.argtypes = [
ctypes.c_ssize_t, # hPeerDist : INT_PTR
wintypes.DWORD, # cbContentIdentifier : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pContentIdentifier : BYTE*
ctypes.c_ulonglong, # ullContentOffset : ULONGLONG
ctypes.c_ulonglong, # cbContentLength : ULONGLONG
ctypes.c_void_p, # pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS*
wintypes.HANDLE, # hCompletionPort : HANDLE optional
ctypes.c_size_t, # ulCompletionKey : UINT_PTR optional
ctypes.POINTER(ctypes.c_ssize_t), # phContentInfo : INT_PTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('PeerDist.dll')
PeerDistServerOpenContentInformationEx = Fiddle::Function.new(
lib['PeerDistServerOpenContentInformationEx'],
[
Fiddle::TYPE_INTPTR_T, # hPeerDist : INT_PTR
-Fiddle::TYPE_INT, # cbContentIdentifier : DWORD
Fiddle::TYPE_VOIDP, # pContentIdentifier : BYTE*
-Fiddle::TYPE_LONG_LONG, # ullContentOffset : ULONGLONG
-Fiddle::TYPE_LONG_LONG, # cbContentLength : ULONGLONG
Fiddle::TYPE_VOIDP, # pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS*
Fiddle::TYPE_VOIDP, # hCompletionPort : HANDLE optional
Fiddle::TYPE_UINTPTR_T, # ulCompletionKey : UINT_PTR optional
Fiddle::TYPE_VOIDP, # phContentInfo : INT_PTR* out
],
-Fiddle::TYPE_INT)#[link(name = "peerdist")]
extern "system" {
fn PeerDistServerOpenContentInformationEx(
hPeerDist: isize, // INT_PTR
cbContentIdentifier: u32, // DWORD
pContentIdentifier: *mut u8, // BYTE*
ullContentOffset: u64, // ULONGLONG
cbContentLength: u64, // ULONGLONG
pRetrievalOptions: *mut PEERDIST_RETRIEVAL_OPTIONS, // PEERDIST_RETRIEVAL_OPTIONS*
hCompletionPort: *mut core::ffi::c_void, // HANDLE optional
ulCompletionKey: usize, // UINT_PTR optional
phContentInfo: *mut isize // INT_PTR* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("PeerDist.dll")]
public static extern uint PeerDistServerOpenContentInformationEx(IntPtr hPeerDist, uint cbContentIdentifier, IntPtr pContentIdentifier, ulong ullContentOffset, ulong cbContentLength, IntPtr pRetrievalOptions, IntPtr hCompletionPort, UIntPtr ulCompletionKey, out IntPtr phContentInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'PeerDist_PeerDistServerOpenContentInformationEx' -Namespace Win32 -PassThru
# $api::PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo)#uselib "PeerDist.dll"
#func global PeerDistServerOpenContentInformationEx "PeerDistServerOpenContentInformationEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; PeerDistServerOpenContentInformationEx hPeerDist, cbContentIdentifier, varptr(pContentIdentifier), ullContentOffset, cbContentLength, varptr(pRetrievalOptions), hCompletionPort, ulCompletionKey, varptr(phContentInfo) ; 戻り値は stat
; hPeerDist : INT_PTR -> "sptr"
; cbContentIdentifier : DWORD -> "sptr"
; pContentIdentifier : BYTE* -> "sptr"
; ullContentOffset : ULONGLONG -> "sptr"
; cbContentLength : ULONGLONG -> "sptr"
; pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> "sptr"
; hCompletionPort : HANDLE optional -> "sptr"
; ulCompletionKey : UINT_PTR optional -> "sptr"
; phContentInfo : INT_PTR* out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "PeerDist.dll" #cfunc global PeerDistServerOpenContentInformationEx "PeerDistServerOpenContentInformationEx" sptr, int, var, int64, int64, var, sptr, sptr, var ; res = PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo) ; hPeerDist : INT_PTR -> "sptr" ; cbContentIdentifier : DWORD -> "int" ; pContentIdentifier : BYTE* -> "var" ; ullContentOffset : ULONGLONG -> "int64" ; cbContentLength : ULONGLONG -> "int64" ; pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> "var" ; hCompletionPort : HANDLE optional -> "sptr" ; ulCompletionKey : UINT_PTR optional -> "sptr" ; phContentInfo : INT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "PeerDist.dll" #cfunc global PeerDistServerOpenContentInformationEx "PeerDistServerOpenContentInformationEx" sptr, int, sptr, int64, int64, sptr, sptr, sptr, sptr ; res = PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, varptr(pContentIdentifier), ullContentOffset, cbContentLength, varptr(pRetrievalOptions), hCompletionPort, ulCompletionKey, varptr(phContentInfo)) ; hPeerDist : INT_PTR -> "sptr" ; cbContentIdentifier : DWORD -> "int" ; pContentIdentifier : BYTE* -> "sptr" ; ullContentOffset : ULONGLONG -> "int64" ; cbContentLength : ULONGLONG -> "int64" ; pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> "sptr" ; hCompletionPort : HANDLE optional -> "sptr" ; ulCompletionKey : UINT_PTR optional -> "sptr" ; phContentInfo : INT_PTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD PeerDistServerOpenContentInformationEx(INT_PTR hPeerDist, DWORD cbContentIdentifier, BYTE* pContentIdentifier, ULONGLONG ullContentOffset, ULONGLONG cbContentLength, PEERDIST_RETRIEVAL_OPTIONS* pRetrievalOptions, HANDLE hCompletionPort, UINT_PTR ulCompletionKey, INT_PTR* phContentInfo) #uselib "PeerDist.dll" #cfunc global PeerDistServerOpenContentInformationEx "PeerDistServerOpenContentInformationEx" intptr, int, var, int64, int64, var, intptr, intptr, var ; res = PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo) ; hPeerDist : INT_PTR -> "intptr" ; cbContentIdentifier : DWORD -> "int" ; pContentIdentifier : BYTE* -> "var" ; ullContentOffset : ULONGLONG -> "int64" ; cbContentLength : ULONGLONG -> "int64" ; pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> "var" ; hCompletionPort : HANDLE optional -> "intptr" ; ulCompletionKey : UINT_PTR optional -> "intptr" ; phContentInfo : INT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PeerDistServerOpenContentInformationEx(INT_PTR hPeerDist, DWORD cbContentIdentifier, BYTE* pContentIdentifier, ULONGLONG ullContentOffset, ULONGLONG cbContentLength, PEERDIST_RETRIEVAL_OPTIONS* pRetrievalOptions, HANDLE hCompletionPort, UINT_PTR ulCompletionKey, INT_PTR* phContentInfo) #uselib "PeerDist.dll" #cfunc global PeerDistServerOpenContentInformationEx "PeerDistServerOpenContentInformationEx" intptr, int, intptr, int64, int64, intptr, intptr, intptr, intptr ; res = PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, varptr(pContentIdentifier), ullContentOffset, cbContentLength, varptr(pRetrievalOptions), hCompletionPort, ulCompletionKey, varptr(phContentInfo)) ; hPeerDist : INT_PTR -> "intptr" ; cbContentIdentifier : DWORD -> "int" ; pContentIdentifier : BYTE* -> "intptr" ; ullContentOffset : ULONGLONG -> "int64" ; cbContentLength : ULONGLONG -> "int64" ; pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> "intptr" ; hCompletionPort : HANDLE optional -> "intptr" ; ulCompletionKey : UINT_PTR optional -> "intptr" ; phContentInfo : INT_PTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
peerdist = windows.NewLazySystemDLL("PeerDist.dll")
procPeerDistServerOpenContentInformationEx = peerdist.NewProc("PeerDistServerOpenContentInformationEx")
)
// hPeerDist (INT_PTR), cbContentIdentifier (DWORD), pContentIdentifier (BYTE*), ullContentOffset (ULONGLONG), cbContentLength (ULONGLONG), pRetrievalOptions (PEERDIST_RETRIEVAL_OPTIONS*), hCompletionPort (HANDLE optional), ulCompletionKey (UINT_PTR optional), phContentInfo (INT_PTR* out)
r1, _, err := procPeerDistServerOpenContentInformationEx.Call(
uintptr(hPeerDist),
uintptr(cbContentIdentifier),
uintptr(pContentIdentifier),
uintptr(ullContentOffset),
uintptr(cbContentLength),
uintptr(pRetrievalOptions),
uintptr(hCompletionPort),
uintptr(ulCompletionKey),
uintptr(phContentInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PeerDistServerOpenContentInformationEx(
hPeerDist: NativeInt; // INT_PTR
cbContentIdentifier: DWORD; // DWORD
pContentIdentifier: Pointer; // BYTE*
ullContentOffset: UInt64; // ULONGLONG
cbContentLength: UInt64; // ULONGLONG
pRetrievalOptions: Pointer; // PEERDIST_RETRIEVAL_OPTIONS*
hCompletionPort: THandle; // HANDLE optional
ulCompletionKey: NativeUInt; // UINT_PTR optional
phContentInfo: Pointer // INT_PTR* out
): DWORD; stdcall;
external 'PeerDist.dll' name 'PeerDistServerOpenContentInformationEx';result := DllCall("PeerDist\PeerDistServerOpenContentInformationEx"
, "Ptr", hPeerDist ; INT_PTR
, "UInt", cbContentIdentifier ; DWORD
, "Ptr", pContentIdentifier ; BYTE*
, "Int64", ullContentOffset ; ULONGLONG
, "Int64", cbContentLength ; ULONGLONG
, "Ptr", pRetrievalOptions ; PEERDIST_RETRIEVAL_OPTIONS*
, "Ptr", hCompletionPort ; HANDLE optional
, "UPtr", ulCompletionKey ; UINT_PTR optional
, "Ptr", phContentInfo ; INT_PTR* out
, "UInt") ; return: DWORD●PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo) = DLL("PeerDist.dll", "dword PeerDistServerOpenContentInformationEx(int, dword, void*, qword, qword, void*, void*, int, void*)")
# 呼び出し: PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo)
# hPeerDist : INT_PTR -> "int"
# cbContentIdentifier : DWORD -> "dword"
# pContentIdentifier : BYTE* -> "void*"
# ullContentOffset : ULONGLONG -> "qword"
# cbContentLength : ULONGLONG -> "qword"
# pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> "void*"
# hCompletionPort : HANDLE optional -> "void*"
# ulCompletionKey : UINT_PTR optional -> "int"
# phContentInfo : INT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "peerdist" fn PeerDistServerOpenContentInformationEx(
hPeerDist: isize, // INT_PTR
cbContentIdentifier: u32, // DWORD
pContentIdentifier: [*c]u8, // BYTE*
ullContentOffset: u64, // ULONGLONG
cbContentLength: u64, // ULONGLONG
pRetrievalOptions: [*c]PEERDIST_RETRIEVAL_OPTIONS, // PEERDIST_RETRIEVAL_OPTIONS*
hCompletionPort: ?*anyopaque, // HANDLE optional
ulCompletionKey: usize, // UINT_PTR optional
phContentInfo: [*c]isize // INT_PTR* out
) callconv(std.os.windows.WINAPI) u32;proc PeerDistServerOpenContentInformationEx(
hPeerDist: int, # INT_PTR
cbContentIdentifier: uint32, # DWORD
pContentIdentifier: ptr uint8, # BYTE*
ullContentOffset: uint64, # ULONGLONG
cbContentLength: uint64, # ULONGLONG
pRetrievalOptions: ptr PEERDIST_RETRIEVAL_OPTIONS, # PEERDIST_RETRIEVAL_OPTIONS*
hCompletionPort: pointer, # HANDLE optional
ulCompletionKey: uint, # UINT_PTR optional
phContentInfo: ptr int # INT_PTR* out
): uint32 {.importc: "PeerDistServerOpenContentInformationEx", stdcall, dynlib: "PeerDist.dll".}pragma(lib, "peerdist");
extern(Windows)
uint PeerDistServerOpenContentInformationEx(
ptrdiff_t hPeerDist, // INT_PTR
uint cbContentIdentifier, // DWORD
ubyte* pContentIdentifier, // BYTE*
ulong ullContentOffset, // ULONGLONG
ulong cbContentLength, // ULONGLONG
PEERDIST_RETRIEVAL_OPTIONS* pRetrievalOptions, // PEERDIST_RETRIEVAL_OPTIONS*
void* hCompletionPort, // HANDLE optional
size_t ulCompletionKey, // UINT_PTR optional
ptrdiff_t* phContentInfo // INT_PTR* out
);ccall((:PeerDistServerOpenContentInformationEx, "PeerDist.dll"), stdcall, UInt32,
(Int, UInt32, Ptr{UInt8}, UInt64, UInt64, Ptr{PEERDIST_RETRIEVAL_OPTIONS}, Ptr{Cvoid}, Csize_t, Ptr{Int}),
hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo)
# hPeerDist : INT_PTR -> Int
# cbContentIdentifier : DWORD -> UInt32
# pContentIdentifier : BYTE* -> Ptr{UInt8}
# ullContentOffset : ULONGLONG -> UInt64
# cbContentLength : ULONGLONG -> UInt64
# pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> Ptr{PEERDIST_RETRIEVAL_OPTIONS}
# hCompletionPort : HANDLE optional -> Ptr{Cvoid}
# ulCompletionKey : UINT_PTR optional -> Csize_t
# phContentInfo : INT_PTR* out -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t PeerDistServerOpenContentInformationEx(
intptr_t hPeerDist,
uint32_t cbContentIdentifier,
uint8_t* pContentIdentifier,
uint64_t ullContentOffset,
uint64_t cbContentLength,
void* pRetrievalOptions,
void* hCompletionPort,
uintptr_t ulCompletionKey,
intptr_t* phContentInfo);
]]
local peerdist = ffi.load("peerdist")
-- peerdist.PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo)
-- hPeerDist : INT_PTR
-- cbContentIdentifier : DWORD
-- pContentIdentifier : BYTE*
-- ullContentOffset : ULONGLONG
-- cbContentLength : ULONGLONG
-- pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS*
-- hCompletionPort : HANDLE optional
-- ulCompletionKey : UINT_PTR optional
-- phContentInfo : INT_PTR* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('PeerDist.dll');
const PeerDistServerOpenContentInformationEx = lib.func('__stdcall', 'PeerDistServerOpenContentInformationEx', 'uint32_t', ['intptr_t', 'uint32_t', 'uint8_t *', 'uint64_t', 'uint64_t', 'void *', 'void *', 'uintptr_t', 'intptr_t *']);
// PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo)
// hPeerDist : INT_PTR -> 'intptr_t'
// cbContentIdentifier : DWORD -> 'uint32_t'
// pContentIdentifier : BYTE* -> 'uint8_t *'
// ullContentOffset : ULONGLONG -> 'uint64_t'
// cbContentLength : ULONGLONG -> 'uint64_t'
// pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> 'void *'
// hCompletionPort : HANDLE optional -> 'void *'
// ulCompletionKey : UINT_PTR optional -> 'uintptr_t'
// phContentInfo : INT_PTR* out -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("PeerDist.dll", {
PeerDistServerOpenContentInformationEx: { parameters: ["isize", "u32", "pointer", "u64", "u64", "pointer", "pointer", "usize", "pointer"], result: "u32" },
});
// lib.symbols.PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo)
// hPeerDist : INT_PTR -> "isize"
// cbContentIdentifier : DWORD -> "u32"
// pContentIdentifier : BYTE* -> "pointer"
// ullContentOffset : ULONGLONG -> "u64"
// cbContentLength : ULONGLONG -> "u64"
// pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> "pointer"
// hCompletionPort : HANDLE optional -> "pointer"
// ulCompletionKey : UINT_PTR optional -> "usize"
// phContentInfo : INT_PTR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PeerDistServerOpenContentInformationEx(
intptr_t hPeerDist,
uint32_t cbContentIdentifier,
uint8_t* pContentIdentifier,
uint64_t ullContentOffset,
uint64_t cbContentLength,
void* pRetrievalOptions,
void* hCompletionPort,
size_t ulCompletionKey,
intptr_t* phContentInfo);
C, "PeerDist.dll");
// $ffi->PeerDistServerOpenContentInformationEx(hPeerDist, cbContentIdentifier, pContentIdentifier, ullContentOffset, cbContentLength, pRetrievalOptions, hCompletionPort, ulCompletionKey, phContentInfo);
// hPeerDist : INT_PTR
// cbContentIdentifier : DWORD
// pContentIdentifier : BYTE*
// ullContentOffset : ULONGLONG
// cbContentLength : ULONGLONG
// pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS*
// hCompletionPort : HANDLE optional
// ulCompletionKey : UINT_PTR optional
// phContentInfo : INT_PTR* 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 Peerdist extends StdCallLibrary {
Peerdist INSTANCE = Native.load("peerdist", Peerdist.class);
int PeerDistServerOpenContentInformationEx(
long hPeerDist, // INT_PTR
int cbContentIdentifier, // DWORD
byte[] pContentIdentifier, // BYTE*
long ullContentOffset, // ULONGLONG
long cbContentLength, // ULONGLONG
Pointer pRetrievalOptions, // PEERDIST_RETRIEVAL_OPTIONS*
Pointer hCompletionPort, // HANDLE optional
long ulCompletionKey, // UINT_PTR optional
LongByReference phContentInfo // INT_PTR* out
);
}@[Link("peerdist")]
lib LibPeerDist
fun PeerDistServerOpenContentInformationEx = PeerDistServerOpenContentInformationEx(
hPeerDist : LibC::SSizeT, # INT_PTR
cbContentIdentifier : UInt32, # DWORD
pContentIdentifier : UInt8*, # BYTE*
ullContentOffset : UInt64, # ULONGLONG
cbContentLength : UInt64, # ULONGLONG
pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS*, # PEERDIST_RETRIEVAL_OPTIONS*
hCompletionPort : Void*, # HANDLE optional
ulCompletionKey : LibC::SizeT, # UINT_PTR optional
phContentInfo : LibC::SSizeT* # INT_PTR* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PeerDistServerOpenContentInformationExNative = Uint32 Function(IntPtr, Uint32, Pointer<Uint8>, Uint64, Uint64, Pointer<Void>, Pointer<Void>, UintPtr, Pointer<IntPtr>);
typedef PeerDistServerOpenContentInformationExDart = int Function(int, int, Pointer<Uint8>, int, int, Pointer<Void>, Pointer<Void>, int, Pointer<IntPtr>);
final PeerDistServerOpenContentInformationEx = DynamicLibrary.open('PeerDist.dll')
.lookupFunction<PeerDistServerOpenContentInformationExNative, PeerDistServerOpenContentInformationExDart>('PeerDistServerOpenContentInformationEx');
// hPeerDist : INT_PTR -> IntPtr
// cbContentIdentifier : DWORD -> Uint32
// pContentIdentifier : BYTE* -> Pointer<Uint8>
// ullContentOffset : ULONGLONG -> Uint64
// cbContentLength : ULONGLONG -> Uint64
// pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> Pointer<Void>
// hCompletionPort : HANDLE optional -> Pointer<Void>
// ulCompletionKey : UINT_PTR optional -> UintPtr
// phContentInfo : INT_PTR* out -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PeerDistServerOpenContentInformationEx(
hPeerDist: NativeInt; // INT_PTR
cbContentIdentifier: DWORD; // DWORD
pContentIdentifier: Pointer; // BYTE*
ullContentOffset: UInt64; // ULONGLONG
cbContentLength: UInt64; // ULONGLONG
pRetrievalOptions: Pointer; // PEERDIST_RETRIEVAL_OPTIONS*
hCompletionPort: THandle; // HANDLE optional
ulCompletionKey: NativeUInt; // UINT_PTR optional
phContentInfo: Pointer // INT_PTR* out
): DWORD; stdcall;
external 'PeerDist.dll' name 'PeerDistServerOpenContentInformationEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PeerDistServerOpenContentInformationEx"
c_PeerDistServerOpenContentInformationEx :: CIntPtr -> Word32 -> Ptr Word8 -> Word64 -> Word64 -> Ptr () -> Ptr () -> CUIntPtr -> Ptr CIntPtr -> IO Word32
-- hPeerDist : INT_PTR -> CIntPtr
-- cbContentIdentifier : DWORD -> Word32
-- pContentIdentifier : BYTE* -> Ptr Word8
-- ullContentOffset : ULONGLONG -> Word64
-- cbContentLength : ULONGLONG -> Word64
-- pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> Ptr ()
-- hCompletionPort : HANDLE optional -> Ptr ()
-- ulCompletionKey : UINT_PTR optional -> CUIntPtr
-- phContentInfo : INT_PTR* out -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let peerdistserveropencontentinformationex =
foreign "PeerDistServerOpenContentInformationEx"
(intptr_t @-> uint32_t @-> (ptr uint8_t) @-> uint64_t @-> uint64_t @-> (ptr void) @-> (ptr void) @-> size_t @-> (ptr intptr_t) @-> returning uint32_t)
(* hPeerDist : INT_PTR -> intptr_t *)
(* cbContentIdentifier : DWORD -> uint32_t *)
(* pContentIdentifier : BYTE* -> (ptr uint8_t) *)
(* ullContentOffset : ULONGLONG -> uint64_t *)
(* cbContentLength : ULONGLONG -> uint64_t *)
(* pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> (ptr void) *)
(* hCompletionPort : HANDLE optional -> (ptr void) *)
(* ulCompletionKey : UINT_PTR optional -> size_t *)
(* phContentInfo : INT_PTR* out -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library peerdist (t "PeerDist.dll"))
(cffi:use-foreign-library peerdist)
(cffi:defcfun ("PeerDistServerOpenContentInformationEx" peer-dist-server-open-content-information-ex :convention :stdcall) :uint32
(h-peer-dist :int64) ; INT_PTR
(cb-content-identifier :uint32) ; DWORD
(p-content-identifier :pointer) ; BYTE*
(ull-content-offset :uint64) ; ULONGLONG
(cb-content-length :uint64) ; ULONGLONG
(p-retrieval-options :pointer) ; PEERDIST_RETRIEVAL_OPTIONS*
(h-completion-port :pointer) ; HANDLE optional
(ul-completion-key :uint64) ; UINT_PTR optional
(ph-content-info :pointer)) ; INT_PTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PeerDistServerOpenContentInformationEx = Win32::API::More->new('PeerDist',
'DWORD PeerDistServerOpenContentInformationEx(LPARAM hPeerDist, DWORD cbContentIdentifier, LPVOID pContentIdentifier, UINT64 ullContentOffset, UINT64 cbContentLength, LPVOID pRetrievalOptions, HANDLE hCompletionPort, WPARAM ulCompletionKey, LPVOID phContentInfo)');
# my $ret = $PeerDistServerOpenContentInformationEx->Call($hPeerDist, $cbContentIdentifier, $pContentIdentifier, $ullContentOffset, $cbContentLength, $pRetrievalOptions, $hCompletionPort, $ulCompletionKey, $phContentInfo);
# hPeerDist : INT_PTR -> LPARAM
# cbContentIdentifier : DWORD -> DWORD
# pContentIdentifier : BYTE* -> LPVOID
# ullContentOffset : ULONGLONG -> UINT64
# cbContentLength : ULONGLONG -> UINT64
# pRetrievalOptions : PEERDIST_RETRIEVAL_OPTIONS* -> LPVOID
# hCompletionPort : HANDLE optional -> HANDLE
# ulCompletionKey : UINT_PTR optional -> WPARAM
# phContentInfo : INT_PTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f PeerDistServerOpenContentInformation — 公開コンテンツの情報取得用ハンドルを開く。