ホーム › NetworkManagement.P2P › PeerDistServerPublishStream
PeerDistServerPublishStream
関数サーバー側でコンテンツストリームの公開を開始する。
シグネチャ
// PeerDist.dll
#include <windows.h>
DWORD PeerDistServerPublishStream(
INT_PTR hPeerDist,
DWORD cbContentIdentifier,
BYTE* pContentIdentifier,
ULONGLONG cbContentLength,
PEERDIST_PUBLICATION_OPTIONS* pPublishOptions, // optional
HANDLE hCompletionPort, // optional
UINT_PTR ulCompletionKey, // optional
INT_PTR* phStream
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hPeerDist | INT_PTR | in |
| cbContentIdentifier | DWORD | in |
| pContentIdentifier | BYTE* | in |
| cbContentLength | ULONGLONG | in |
| pPublishOptions | PEERDIST_PUBLICATION_OPTIONS* | inoptional |
| hCompletionPort | HANDLE | inoptional |
| ulCompletionKey | UINT_PTR | inoptional |
| phStream | INT_PTR* | out |
戻り値の型: DWORD
各言語での呼び出し定義
// PeerDist.dll
#include <windows.h>
DWORD PeerDistServerPublishStream(
INT_PTR hPeerDist,
DWORD cbContentIdentifier,
BYTE* pContentIdentifier,
ULONGLONG cbContentLength,
PEERDIST_PUBLICATION_OPTIONS* pPublishOptions, // optional
HANDLE hCompletionPort, // optional
UINT_PTR ulCompletionKey, // optional
INT_PTR* phStream
);[DllImport("PeerDist.dll", ExactSpelling = true)]
static extern uint PeerDistServerPublishStream(
IntPtr hPeerDist, // INT_PTR
uint cbContentIdentifier, // DWORD
IntPtr pContentIdentifier, // BYTE*
ulong cbContentLength, // ULONGLONG
IntPtr pPublishOptions, // PEERDIST_PUBLICATION_OPTIONS* optional
IntPtr hCompletionPort, // HANDLE optional
UIntPtr ulCompletionKey, // UINT_PTR optional
out IntPtr phStream // INT_PTR* out
);<DllImport("PeerDist.dll", ExactSpelling:=True)>
Public Shared Function PeerDistServerPublishStream(
hPeerDist As IntPtr, ' INT_PTR
cbContentIdentifier As UInteger, ' DWORD
pContentIdentifier As IntPtr, ' BYTE*
cbContentLength As ULong, ' ULONGLONG
pPublishOptions As IntPtr, ' PEERDIST_PUBLICATION_OPTIONS* optional
hCompletionPort As IntPtr, ' HANDLE optional
ulCompletionKey As UIntPtr, ' UINT_PTR optional
<Out> ByRef phStream As IntPtr ' INT_PTR* out
) As UInteger
End Function' hPeerDist : INT_PTR
' cbContentIdentifier : DWORD
' pContentIdentifier : BYTE*
' cbContentLength : ULONGLONG
' pPublishOptions : PEERDIST_PUBLICATION_OPTIONS* optional
' hCompletionPort : HANDLE optional
' ulCompletionKey : UINT_PTR optional
' phStream : INT_PTR* out
Declare PtrSafe Function PeerDistServerPublishStream Lib "peerdist" ( _
ByVal hPeerDist As LongPtr, _
ByVal cbContentIdentifier As Long, _
ByVal pContentIdentifier As LongPtr, _
ByVal cbContentLength As LongLong, _
ByVal pPublishOptions As LongPtr, _
ByVal hCompletionPort As LongPtr, _
ByVal ulCompletionKey As LongPtr, _
ByRef phStream As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PeerDistServerPublishStream = ctypes.windll.peerdist.PeerDistServerPublishStream
PeerDistServerPublishStream.restype = wintypes.DWORD
PeerDistServerPublishStream.argtypes = [
ctypes.c_ssize_t, # hPeerDist : INT_PTR
wintypes.DWORD, # cbContentIdentifier : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pContentIdentifier : BYTE*
ctypes.c_ulonglong, # cbContentLength : ULONGLONG
ctypes.c_void_p, # pPublishOptions : PEERDIST_PUBLICATION_OPTIONS* optional
wintypes.HANDLE, # hCompletionPort : HANDLE optional
ctypes.c_size_t, # ulCompletionKey : UINT_PTR optional
ctypes.POINTER(ctypes.c_ssize_t), # phStream : INT_PTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('PeerDist.dll')
PeerDistServerPublishStream = Fiddle::Function.new(
lib['PeerDistServerPublishStream'],
[
Fiddle::TYPE_INTPTR_T, # hPeerDist : INT_PTR
-Fiddle::TYPE_INT, # cbContentIdentifier : DWORD
Fiddle::TYPE_VOIDP, # pContentIdentifier : BYTE*
-Fiddle::TYPE_LONG_LONG, # cbContentLength : ULONGLONG
Fiddle::TYPE_VOIDP, # pPublishOptions : PEERDIST_PUBLICATION_OPTIONS* optional
Fiddle::TYPE_VOIDP, # hCompletionPort : HANDLE optional
Fiddle::TYPE_UINTPTR_T, # ulCompletionKey : UINT_PTR optional
Fiddle::TYPE_VOIDP, # phStream : INT_PTR* out
],
-Fiddle::TYPE_INT)#[link(name = "peerdist")]
extern "system" {
fn PeerDistServerPublishStream(
hPeerDist: isize, // INT_PTR
cbContentIdentifier: u32, // DWORD
pContentIdentifier: *mut u8, // BYTE*
cbContentLength: u64, // ULONGLONG
pPublishOptions: *mut PEERDIST_PUBLICATION_OPTIONS, // PEERDIST_PUBLICATION_OPTIONS* optional
hCompletionPort: *mut core::ffi::c_void, // HANDLE optional
ulCompletionKey: usize, // UINT_PTR optional
phStream: *mut isize // INT_PTR* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("PeerDist.dll")]
public static extern uint PeerDistServerPublishStream(IntPtr hPeerDist, uint cbContentIdentifier, IntPtr pContentIdentifier, ulong cbContentLength, IntPtr pPublishOptions, IntPtr hCompletionPort, UIntPtr ulCompletionKey, out IntPtr phStream);
"@
$api = Add-Type -MemberDefinition $sig -Name 'PeerDist_PeerDistServerPublishStream' -Namespace Win32 -PassThru
# $api::PeerDistServerPublishStream(hPeerDist, cbContentIdentifier, pContentIdentifier, cbContentLength, pPublishOptions, hCompletionPort, ulCompletionKey, phStream)#uselib "PeerDist.dll"
#func global PeerDistServerPublishStream "PeerDistServerPublishStream" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; PeerDistServerPublishStream hPeerDist, cbContentIdentifier, varptr(pContentIdentifier), cbContentLength, varptr(pPublishOptions), hCompletionPort, ulCompletionKey, varptr(phStream) ; 戻り値は stat
; hPeerDist : INT_PTR -> "sptr"
; cbContentIdentifier : DWORD -> "sptr"
; pContentIdentifier : BYTE* -> "sptr"
; cbContentLength : ULONGLONG -> "sptr"
; pPublishOptions : PEERDIST_PUBLICATION_OPTIONS* optional -> "sptr"
; hCompletionPort : HANDLE optional -> "sptr"
; ulCompletionKey : UINT_PTR optional -> "sptr"
; phStream : INT_PTR* out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "PeerDist.dll" #cfunc global PeerDistServerPublishStream "PeerDistServerPublishStream" sptr, int, var, int64, var, sptr, sptr, var ; res = PeerDistServerPublishStream(hPeerDist, cbContentIdentifier, pContentIdentifier, cbContentLength, pPublishOptions, hCompletionPort, ulCompletionKey, phStream) ; hPeerDist : INT_PTR -> "sptr" ; cbContentIdentifier : DWORD -> "int" ; pContentIdentifier : BYTE* -> "var" ; cbContentLength : ULONGLONG -> "int64" ; pPublishOptions : PEERDIST_PUBLICATION_OPTIONS* optional -> "var" ; hCompletionPort : HANDLE optional -> "sptr" ; ulCompletionKey : UINT_PTR optional -> "sptr" ; phStream : INT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "PeerDist.dll" #cfunc global PeerDistServerPublishStream "PeerDistServerPublishStream" sptr, int, sptr, int64, sptr, sptr, sptr, sptr ; res = PeerDistServerPublishStream(hPeerDist, cbContentIdentifier, varptr(pContentIdentifier), cbContentLength, varptr(pPublishOptions), hCompletionPort, ulCompletionKey, varptr(phStream)) ; hPeerDist : INT_PTR -> "sptr" ; cbContentIdentifier : DWORD -> "int" ; pContentIdentifier : BYTE* -> "sptr" ; cbContentLength : ULONGLONG -> "int64" ; pPublishOptions : PEERDIST_PUBLICATION_OPTIONS* optional -> "sptr" ; hCompletionPort : HANDLE optional -> "sptr" ; ulCompletionKey : UINT_PTR optional -> "sptr" ; phStream : INT_PTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD PeerDistServerPublishStream(INT_PTR hPeerDist, DWORD cbContentIdentifier, BYTE* pContentIdentifier, ULONGLONG cbContentLength, PEERDIST_PUBLICATION_OPTIONS* pPublishOptions, HANDLE hCompletionPort, UINT_PTR ulCompletionKey, INT_PTR* phStream) #uselib "PeerDist.dll" #cfunc global PeerDistServerPublishStream "PeerDistServerPublishStream" intptr, int, var, int64, var, intptr, intptr, var ; res = PeerDistServerPublishStream(hPeerDist, cbContentIdentifier, pContentIdentifier, cbContentLength, pPublishOptions, hCompletionPort, ulCompletionKey, phStream) ; hPeerDist : INT_PTR -> "intptr" ; cbContentIdentifier : DWORD -> "int" ; pContentIdentifier : BYTE* -> "var" ; cbContentLength : ULONGLONG -> "int64" ; pPublishOptions : PEERDIST_PUBLICATION_OPTIONS* optional -> "var" ; hCompletionPort : HANDLE optional -> "intptr" ; ulCompletionKey : UINT_PTR optional -> "intptr" ; phStream : INT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PeerDistServerPublishStream(INT_PTR hPeerDist, DWORD cbContentIdentifier, BYTE* pContentIdentifier, ULONGLONG cbContentLength, PEERDIST_PUBLICATION_OPTIONS* pPublishOptions, HANDLE hCompletionPort, UINT_PTR ulCompletionKey, INT_PTR* phStream) #uselib "PeerDist.dll" #cfunc global PeerDistServerPublishStream "PeerDistServerPublishStream" intptr, int, intptr, int64, intptr, intptr, intptr, intptr ; res = PeerDistServerPublishStream(hPeerDist, cbContentIdentifier, varptr(pContentIdentifier), cbContentLength, varptr(pPublishOptions), hCompletionPort, ulCompletionKey, varptr(phStream)) ; hPeerDist : INT_PTR -> "intptr" ; cbContentIdentifier : DWORD -> "int" ; pContentIdentifier : BYTE* -> "intptr" ; cbContentLength : ULONGLONG -> "int64" ; pPublishOptions : PEERDIST_PUBLICATION_OPTIONS* optional -> "intptr" ; hCompletionPort : HANDLE optional -> "intptr" ; ulCompletionKey : UINT_PTR optional -> "intptr" ; phStream : INT_PTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
peerdist = windows.NewLazySystemDLL("PeerDist.dll")
procPeerDistServerPublishStream = peerdist.NewProc("PeerDistServerPublishStream")
)
// hPeerDist (INT_PTR), cbContentIdentifier (DWORD), pContentIdentifier (BYTE*), cbContentLength (ULONGLONG), pPublishOptions (PEERDIST_PUBLICATION_OPTIONS* optional), hCompletionPort (HANDLE optional), ulCompletionKey (UINT_PTR optional), phStream (INT_PTR* out)
r1, _, err := procPeerDistServerPublishStream.Call(
uintptr(hPeerDist),
uintptr(cbContentIdentifier),
uintptr(pContentIdentifier),
uintptr(cbContentLength),
uintptr(pPublishOptions),
uintptr(hCompletionPort),
uintptr(ulCompletionKey),
uintptr(phStream),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PeerDistServerPublishStream(
hPeerDist: NativeInt; // INT_PTR
cbContentIdentifier: DWORD; // DWORD
pContentIdentifier: Pointer; // BYTE*
cbContentLength: UInt64; // ULONGLONG
pPublishOptions: Pointer; // PEERDIST_PUBLICATION_OPTIONS* optional
hCompletionPort: THandle; // HANDLE optional
ulCompletionKey: NativeUInt; // UINT_PTR optional
phStream: Pointer // INT_PTR* out
): DWORD; stdcall;
external 'PeerDist.dll' name 'PeerDistServerPublishStream';result := DllCall("PeerDist\PeerDistServerPublishStream"
, "Ptr", hPeerDist ; INT_PTR
, "UInt", cbContentIdentifier ; DWORD
, "Ptr", pContentIdentifier ; BYTE*
, "Int64", cbContentLength ; ULONGLONG
, "Ptr", pPublishOptions ; PEERDIST_PUBLICATION_OPTIONS* optional
, "Ptr", hCompletionPort ; HANDLE optional
, "UPtr", ulCompletionKey ; UINT_PTR optional
, "Ptr", phStream ; INT_PTR* out
, "UInt") ; return: DWORD●PeerDistServerPublishStream(hPeerDist, cbContentIdentifier, pContentIdentifier, cbContentLength, pPublishOptions, hCompletionPort, ulCompletionKey, phStream) = DLL("PeerDist.dll", "dword PeerDistServerPublishStream(int, dword, void*, qword, void*, void*, int, void*)")
# 呼び出し: PeerDistServerPublishStream(hPeerDist, cbContentIdentifier, pContentIdentifier, cbContentLength, pPublishOptions, hCompletionPort, ulCompletionKey, phStream)
# hPeerDist : INT_PTR -> "int"
# cbContentIdentifier : DWORD -> "dword"
# pContentIdentifier : BYTE* -> "void*"
# cbContentLength : ULONGLONG -> "qword"
# pPublishOptions : PEERDIST_PUBLICATION_OPTIONS* optional -> "void*"
# hCompletionPort : HANDLE optional -> "void*"
# ulCompletionKey : UINT_PTR optional -> "int"
# phStream : INT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。