Win32 API 日本語リファレンス
ホームNetworking.WindowsWebServices › WsRegisterOperationForCancel

WsRegisterOperationForCancel

関数
操作のキャンセルコールバックを登録する。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WsRegisterOperationForCancel(
    const WS_OPERATION_CONTEXT* context,
    WS_OPERATION_CANCEL_CALLBACK cancelCallback,
    WS_OPERATION_FREE_STATE_CALLBACK freestateCallback,   // optional
    void* userState,   // optional
    WS_ERROR* error   // optional
);

パラメーター

名前方向
contextWS_OPERATION_CONTEXT*in
cancelCallbackWS_OPERATION_CANCEL_CALLBACKin
freestateCallbackWS_OPERATION_FREE_STATE_CALLBACKinoptional
userStatevoid*inoptional
errorWS_ERROR*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WsRegisterOperationForCancel(
    const WS_OPERATION_CONTEXT* context,
    WS_OPERATION_CANCEL_CALLBACK cancelCallback,
    WS_OPERATION_FREE_STATE_CALLBACK freestateCallback,   // optional
    void* userState,   // optional
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsRegisterOperationForCancel(
    ref IntPtr context,   // WS_OPERATION_CONTEXT*
    IntPtr cancelCallback,   // WS_OPERATION_CANCEL_CALLBACK
    IntPtr freestateCallback,   // WS_OPERATION_FREE_STATE_CALLBACK optional
    IntPtr userState,   // void* optional
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsRegisterOperationForCancel(
    ByRef context As IntPtr,   ' WS_OPERATION_CONTEXT*
    cancelCallback As IntPtr,   ' WS_OPERATION_CANCEL_CALLBACK
    freestateCallback As IntPtr,   ' WS_OPERATION_FREE_STATE_CALLBACK optional
    userState As IntPtr,   ' void* optional
    [error] As IntPtr   ' WS_ERROR* optional
) As Integer
End Function
' context : WS_OPERATION_CONTEXT*
' cancelCallback : WS_OPERATION_CANCEL_CALLBACK
' freestateCallback : WS_OPERATION_FREE_STATE_CALLBACK optional
' userState : void* optional
' error : WS_ERROR* optional
Declare PtrSafe Function WsRegisterOperationForCancel Lib "webservices" ( _
    ByRef context As LongPtr, _
    ByVal cancelCallback As LongPtr, _
    ByVal freestateCallback As LongPtr, _
    ByVal userState As LongPtr, _
    ByVal error As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WsRegisterOperationForCancel = ctypes.windll.webservices.WsRegisterOperationForCancel
WsRegisterOperationForCancel.restype = ctypes.c_int
WsRegisterOperationForCancel.argtypes = [
    ctypes.c_void_p,  # context : WS_OPERATION_CONTEXT*
    ctypes.c_void_p,  # cancelCallback : WS_OPERATION_CANCEL_CALLBACK
    ctypes.c_void_p,  # freestateCallback : WS_OPERATION_FREE_STATE_CALLBACK optional
    ctypes.POINTER(None),  # userState : void* optional
    ctypes.c_void_p,  # error : WS_ERROR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webservices.dll')
WsRegisterOperationForCancel = Fiddle::Function.new(
  lib['WsRegisterOperationForCancel'],
  [
    Fiddle::TYPE_VOIDP,  # context : WS_OPERATION_CONTEXT*
    Fiddle::TYPE_VOIDP,  # cancelCallback : WS_OPERATION_CANCEL_CALLBACK
    Fiddle::TYPE_VOIDP,  # freestateCallback : WS_OPERATION_FREE_STATE_CALLBACK optional
    Fiddle::TYPE_VOIDP,  # userState : void* optional
    Fiddle::TYPE_VOIDP,  # error : WS_ERROR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "webservices")]
extern "system" {
    fn WsRegisterOperationForCancel(
        context: *const isize,  // WS_OPERATION_CONTEXT*
        cancelCallback: *const core::ffi::c_void,  // WS_OPERATION_CANCEL_CALLBACK
        freestateCallback: *const core::ffi::c_void,  // WS_OPERATION_FREE_STATE_CALLBACK optional
        userState: *mut (),  // void* optional
        error: *mut isize  // WS_ERROR* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("webservices.dll")]
public static extern int WsRegisterOperationForCancel(ref IntPtr context, IntPtr cancelCallback, IntPtr freestateCallback, IntPtr userState, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsRegisterOperationForCancel' -Namespace Win32 -PassThru
# $api::WsRegisterOperationForCancel(context, cancelCallback, freestateCallback, userState, error)
#uselib "webservices.dll"
#func global WsRegisterOperationForCancel "WsRegisterOperationForCancel" sptr, sptr, sptr, sptr, sptr
; WsRegisterOperationForCancel context, cancelCallback, freestateCallback, userState, error   ; 戻り値は stat
; context : WS_OPERATION_CONTEXT* -> "sptr"
; cancelCallback : WS_OPERATION_CANCEL_CALLBACK -> "sptr"
; freestateCallback : WS_OPERATION_FREE_STATE_CALLBACK optional -> "sptr"
; userState : void* optional -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "webservices.dll"
#cfunc global WsRegisterOperationForCancel "WsRegisterOperationForCancel" int, sptr, sptr, sptr, int
; res = WsRegisterOperationForCancel(context, cancelCallback, freestateCallback, userState, error)
; context : WS_OPERATION_CONTEXT* -> "int"
; cancelCallback : WS_OPERATION_CANCEL_CALLBACK -> "sptr"
; freestateCallback : WS_OPERATION_FREE_STATE_CALLBACK optional -> "sptr"
; userState : void* optional -> "sptr"
; error : WS_ERROR* optional -> "int"
; HRESULT WsRegisterOperationForCancel(WS_OPERATION_CONTEXT* context, WS_OPERATION_CANCEL_CALLBACK cancelCallback, WS_OPERATION_FREE_STATE_CALLBACK freestateCallback, void* userState, WS_ERROR* error)
#uselib "webservices.dll"
#cfunc global WsRegisterOperationForCancel "WsRegisterOperationForCancel" int, intptr, intptr, intptr, int
; res = WsRegisterOperationForCancel(context, cancelCallback, freestateCallback, userState, error)
; context : WS_OPERATION_CONTEXT* -> "int"
; cancelCallback : WS_OPERATION_CANCEL_CALLBACK -> "intptr"
; freestateCallback : WS_OPERATION_FREE_STATE_CALLBACK optional -> "intptr"
; userState : void* optional -> "intptr"
; error : WS_ERROR* optional -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsRegisterOperationForCancel = webservices.NewProc("WsRegisterOperationForCancel")
)

// context (WS_OPERATION_CONTEXT*), cancelCallback (WS_OPERATION_CANCEL_CALLBACK), freestateCallback (WS_OPERATION_FREE_STATE_CALLBACK optional), userState (void* optional), error (WS_ERROR* optional)
r1, _, err := procWsRegisterOperationForCancel.Call(
	uintptr(context),
	uintptr(cancelCallback),
	uintptr(freestateCallback),
	uintptr(userState),
	uintptr(error),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WsRegisterOperationForCancel(
  context: Pointer;   // WS_OPERATION_CONTEXT*
  cancelCallback: Pointer;   // WS_OPERATION_CANCEL_CALLBACK
  freestateCallback: Pointer;   // WS_OPERATION_FREE_STATE_CALLBACK optional
  userState: Pointer;   // void* optional
  error: Pointer   // WS_ERROR* optional
): Integer; stdcall;
  external 'webservices.dll' name 'WsRegisterOperationForCancel';
result := DllCall("webservices\WsRegisterOperationForCancel"
    , "Ptr", context   ; WS_OPERATION_CONTEXT*
    , "Ptr", cancelCallback   ; WS_OPERATION_CANCEL_CALLBACK
    , "Ptr", freestateCallback   ; WS_OPERATION_FREE_STATE_CALLBACK optional
    , "Ptr", userState   ; void* optional
    , "Ptr", error   ; WS_ERROR* optional
    , "Int")   ; return: HRESULT
●WsRegisterOperationForCancel(context, cancelCallback, freestateCallback, userState, error) = DLL("webservices.dll", "int WsRegisterOperationForCancel(void*, void*, void*, void*, void*)")
# 呼び出し: WsRegisterOperationForCancel(context, cancelCallback, freestateCallback, userState, error)
# context : WS_OPERATION_CONTEXT* -> "void*"
# cancelCallback : WS_OPERATION_CANCEL_CALLBACK -> "void*"
# freestateCallback : WS_OPERATION_FREE_STATE_CALLBACK optional -> "void*"
# userState : void* optional -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。