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

PeerDistClientCancelAsyncOperation

関数
クライアント側の非同期操作をキャンセルする。
DLLPeerDist.dll呼出規約winapiSetLastErrorあり対応OSWindows 7 以降

シグネチャ

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

DWORD PeerDistClientCancelAsyncOperation(
    INT_PTR hPeerDist,
    INT_PTR hContentHandle,
    OVERLAPPED* pOverlapped   // optional
);

パラメーター

名前方向
hPeerDistINT_PTRin
hContentHandleINT_PTRin
pOverlappedOVERLAPPED*inoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD PeerDistClientCancelAsyncOperation(
    INT_PTR hPeerDist,
    INT_PTR hContentHandle,
    OVERLAPPED* pOverlapped   // optional
);
[DllImport("PeerDist.dll", SetLastError = true, ExactSpelling = true)]
static extern uint PeerDistClientCancelAsyncOperation(
    IntPtr hPeerDist,   // INT_PTR
    IntPtr hContentHandle,   // INT_PTR
    IntPtr pOverlapped   // OVERLAPPED* optional
);
<DllImport("PeerDist.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function PeerDistClientCancelAsyncOperation(
    hPeerDist As IntPtr,   ' INT_PTR
    hContentHandle As IntPtr,   ' INT_PTR
    pOverlapped As IntPtr   ' OVERLAPPED* optional
) As UInteger
End Function
' hPeerDist : INT_PTR
' hContentHandle : INT_PTR
' pOverlapped : OVERLAPPED* optional
Declare PtrSafe Function PeerDistClientCancelAsyncOperation Lib "peerdist" ( _
    ByVal hPeerDist As LongPtr, _
    ByVal hContentHandle As LongPtr, _
    ByVal pOverlapped As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PeerDistClientCancelAsyncOperation = ctypes.windll.peerdist.PeerDistClientCancelAsyncOperation
PeerDistClientCancelAsyncOperation.restype = wintypes.DWORD
PeerDistClientCancelAsyncOperation.argtypes = [
    ctypes.c_ssize_t,  # hPeerDist : INT_PTR
    ctypes.c_ssize_t,  # hContentHandle : INT_PTR
    ctypes.c_void_p,  # pOverlapped : OVERLAPPED* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('PeerDist.dll')
PeerDistClientCancelAsyncOperation = Fiddle::Function.new(
  lib['PeerDistClientCancelAsyncOperation'],
  [
    Fiddle::TYPE_INTPTR_T,  # hPeerDist : INT_PTR
    Fiddle::TYPE_INTPTR_T,  # hContentHandle : INT_PTR
    Fiddle::TYPE_VOIDP,  # pOverlapped : OVERLAPPED* optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "peerdist")]
extern "system" {
    fn PeerDistClientCancelAsyncOperation(
        hPeerDist: isize,  // INT_PTR
        hContentHandle: isize,  // INT_PTR
        pOverlapped: *mut OVERLAPPED  // OVERLAPPED* optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("PeerDist.dll", SetLastError = true)]
public static extern uint PeerDistClientCancelAsyncOperation(IntPtr hPeerDist, IntPtr hContentHandle, IntPtr pOverlapped);
"@
$api = Add-Type -MemberDefinition $sig -Name 'PeerDist_PeerDistClientCancelAsyncOperation' -Namespace Win32 -PassThru
# $api::PeerDistClientCancelAsyncOperation(hPeerDist, hContentHandle, pOverlapped)
#uselib "PeerDist.dll"
#func global PeerDistClientCancelAsyncOperation "PeerDistClientCancelAsyncOperation" sptr, sptr, sptr
; PeerDistClientCancelAsyncOperation hPeerDist, hContentHandle, varptr(pOverlapped)   ; 戻り値は stat
; hPeerDist : INT_PTR -> "sptr"
; hContentHandle : INT_PTR -> "sptr"
; pOverlapped : OVERLAPPED* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "PeerDist.dll"
#cfunc global PeerDistClientCancelAsyncOperation "PeerDistClientCancelAsyncOperation" sptr, sptr, var
; res = PeerDistClientCancelAsyncOperation(hPeerDist, hContentHandle, pOverlapped)
; hPeerDist : INT_PTR -> "sptr"
; hContentHandle : INT_PTR -> "sptr"
; pOverlapped : OVERLAPPED* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PeerDistClientCancelAsyncOperation(INT_PTR hPeerDist, INT_PTR hContentHandle, OVERLAPPED* pOverlapped)
#uselib "PeerDist.dll"
#cfunc global PeerDistClientCancelAsyncOperation "PeerDistClientCancelAsyncOperation" intptr, intptr, var
; res = PeerDistClientCancelAsyncOperation(hPeerDist, hContentHandle, pOverlapped)
; hPeerDist : INT_PTR -> "intptr"
; hContentHandle : INT_PTR -> "intptr"
; pOverlapped : OVERLAPPED* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	peerdist = windows.NewLazySystemDLL("PeerDist.dll")
	procPeerDistClientCancelAsyncOperation = peerdist.NewProc("PeerDistClientCancelAsyncOperation")
)

// hPeerDist (INT_PTR), hContentHandle (INT_PTR), pOverlapped (OVERLAPPED* optional)
r1, _, err := procPeerDistClientCancelAsyncOperation.Call(
	uintptr(hPeerDist),
	uintptr(hContentHandle),
	uintptr(pOverlapped),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PeerDistClientCancelAsyncOperation(
  hPeerDist: NativeInt;   // INT_PTR
  hContentHandle: NativeInt;   // INT_PTR
  pOverlapped: Pointer   // OVERLAPPED* optional
): DWORD; stdcall;
  external 'PeerDist.dll' name 'PeerDistClientCancelAsyncOperation';
result := DllCall("PeerDist\PeerDistClientCancelAsyncOperation"
    , "Ptr", hPeerDist   ; INT_PTR
    , "Ptr", hContentHandle   ; INT_PTR
    , "Ptr", pOverlapped   ; OVERLAPPED* optional
    , "UInt")   ; return: DWORD
●PeerDistClientCancelAsyncOperation(hPeerDist, hContentHandle, pOverlapped) = DLL("PeerDist.dll", "dword PeerDistClientCancelAsyncOperation(int, int, void*)")
# 呼び出し: PeerDistClientCancelAsyncOperation(hPeerDist, hContentHandle, pOverlapped)
# hPeerDist : INT_PTR -> "int"
# hContentHandle : INT_PTR -> "int"
# pOverlapped : OVERLAPPED* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。