Win32 API 日本語リファレンス
ホームSystem.Threading › RtwqCreateAsyncResult

RtwqCreateAsyncResult

関数
非同期コールバック用のRTWQ非同期結果オブジェクトを作成する。
DLLRTWorkQ.dll呼出規約winapi対応OSWindows 8.1 以降

シグネチャ

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

HRESULT RtwqCreateAsyncResult(
    IUnknown* appObject,
    IRtwqAsyncCallback* callback,
    IUnknown* appState,
    IRtwqAsyncResult** asyncResult
);

パラメーター

名前方向説明
appObjectIUnknown*in非同期結果に格納されるオブジェクトへのポインター。このポインターは IRtwqAsyncResult::GetObject メソッドによって返されます。このパラメーターは NULL にできます。
callbackIRtwqAsyncCallback*inIRtwqAsyncCallback インターフェイスへのポインター。このインターフェイスは、非同期メソッドの呼び出し元によって実装されます。
appStateIUnknown*in状態オブジェクトの IUnknown インターフェイスへのポインター。この値は、非同期メソッドの呼び出し元によって提供されます。このパラメーターは NULL にできます。
asyncResultIRtwqAsyncResult**outIRtwqAsyncResult インターフェイスへのポインターを受け取ります。呼び出し元は、このインターフェイスを解放する必要があります。

戻り値の型: HRESULT

公式ドキュメント

非同期結果オブジェクトを作成します。非同期メソッドを実装する場合に、この関数を使用します。(RtwqCreateAsyncResult)

戻り値

この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。

解説(Remarks)

pCallback で指定したコールバックを呼び出すには、RtwqInvokeCallback 関数を呼び出します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

HRESULT RtwqCreateAsyncResult(
    IUnknown* appObject,
    IRtwqAsyncCallback* callback,
    IUnknown* appState,
    IRtwqAsyncResult** asyncResult
);
[DllImport("RTWorkQ.dll", ExactSpelling = true)]
static extern int RtwqCreateAsyncResult(
    IntPtr appObject,   // IUnknown*
    IntPtr callback,   // IRtwqAsyncCallback*
    IntPtr appState,   // IUnknown*
    IntPtr asyncResult   // IRtwqAsyncResult** out
);
<DllImport("RTWorkQ.dll", ExactSpelling:=True)>
Public Shared Function RtwqCreateAsyncResult(
    appObject As IntPtr,   ' IUnknown*
    callback As IntPtr,   ' IRtwqAsyncCallback*
    appState As IntPtr,   ' IUnknown*
    asyncResult As IntPtr   ' IRtwqAsyncResult** out
) As Integer
End Function
' appObject : IUnknown*
' callback : IRtwqAsyncCallback*
' appState : IUnknown*
' asyncResult : IRtwqAsyncResult** out
Declare PtrSafe Function RtwqCreateAsyncResult Lib "rtworkq" ( _
    ByVal appObject As LongPtr, _
    ByVal callback As LongPtr, _
    ByVal appState As LongPtr, _
    ByVal asyncResult As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtwqCreateAsyncResult = ctypes.windll.rtworkq.RtwqCreateAsyncResult
RtwqCreateAsyncResult.restype = ctypes.c_int
RtwqCreateAsyncResult.argtypes = [
    ctypes.c_void_p,  # appObject : IUnknown*
    ctypes.c_void_p,  # callback : IRtwqAsyncCallback*
    ctypes.c_void_p,  # appState : IUnknown*
    ctypes.c_void_p,  # asyncResult : IRtwqAsyncResult** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RTWorkQ.dll')
RtwqCreateAsyncResult = Fiddle::Function.new(
  lib['RtwqCreateAsyncResult'],
  [
    Fiddle::TYPE_VOIDP,  # appObject : IUnknown*
    Fiddle::TYPE_VOIDP,  # callback : IRtwqAsyncCallback*
    Fiddle::TYPE_VOIDP,  # appState : IUnknown*
    Fiddle::TYPE_VOIDP,  # asyncResult : IRtwqAsyncResult** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "rtworkq")]
extern "system" {
    fn RtwqCreateAsyncResult(
        appObject: *mut core::ffi::c_void,  // IUnknown*
        callback: *mut core::ffi::c_void,  // IRtwqAsyncCallback*
        appState: *mut core::ffi::c_void,  // IUnknown*
        asyncResult: *mut *mut core::ffi::c_void  // IRtwqAsyncResult** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RTWorkQ.dll")]
public static extern int RtwqCreateAsyncResult(IntPtr appObject, IntPtr callback, IntPtr appState, IntPtr asyncResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RTWorkQ_RtwqCreateAsyncResult' -Namespace Win32 -PassThru
# $api::RtwqCreateAsyncResult(appObject, callback, appState, asyncResult)
#uselib "RTWorkQ.dll"
#func global RtwqCreateAsyncResult "RtwqCreateAsyncResult" sptr, sptr, sptr, sptr
; RtwqCreateAsyncResult appObject, callback, appState, asyncResult   ; 戻り値は stat
; appObject : IUnknown* -> "sptr"
; callback : IRtwqAsyncCallback* -> "sptr"
; appState : IUnknown* -> "sptr"
; asyncResult : IRtwqAsyncResult** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "RTWorkQ.dll"
#cfunc global RtwqCreateAsyncResult "RtwqCreateAsyncResult" sptr, sptr, sptr, sptr
; res = RtwqCreateAsyncResult(appObject, callback, appState, asyncResult)
; appObject : IUnknown* -> "sptr"
; callback : IRtwqAsyncCallback* -> "sptr"
; appState : IUnknown* -> "sptr"
; asyncResult : IRtwqAsyncResult** out -> "sptr"
; HRESULT RtwqCreateAsyncResult(IUnknown* appObject, IRtwqAsyncCallback* callback, IUnknown* appState, IRtwqAsyncResult** asyncResult)
#uselib "RTWorkQ.dll"
#cfunc global RtwqCreateAsyncResult "RtwqCreateAsyncResult" intptr, intptr, intptr, intptr
; res = RtwqCreateAsyncResult(appObject, callback, appState, asyncResult)
; appObject : IUnknown* -> "intptr"
; callback : IRtwqAsyncCallback* -> "intptr"
; appState : IUnknown* -> "intptr"
; asyncResult : IRtwqAsyncResult** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rtworkq = windows.NewLazySystemDLL("RTWorkQ.dll")
	procRtwqCreateAsyncResult = rtworkq.NewProc("RtwqCreateAsyncResult")
)

// appObject (IUnknown*), callback (IRtwqAsyncCallback*), appState (IUnknown*), asyncResult (IRtwqAsyncResult** out)
r1, _, err := procRtwqCreateAsyncResult.Call(
	uintptr(appObject),
	uintptr(callback),
	uintptr(appState),
	uintptr(asyncResult),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function RtwqCreateAsyncResult(
  appObject: Pointer;   // IUnknown*
  callback: Pointer;   // IRtwqAsyncCallback*
  appState: Pointer;   // IUnknown*
  asyncResult: Pointer   // IRtwqAsyncResult** out
): Integer; stdcall;
  external 'RTWorkQ.dll' name 'RtwqCreateAsyncResult';
result := DllCall("RTWorkQ\RtwqCreateAsyncResult"
    , "Ptr", appObject   ; IUnknown*
    , "Ptr", callback   ; IRtwqAsyncCallback*
    , "Ptr", appState   ; IUnknown*
    , "Ptr", asyncResult   ; IRtwqAsyncResult** out
    , "Int")   ; return: HRESULT
●RtwqCreateAsyncResult(appObject, callback, appState, asyncResult) = DLL("RTWorkQ.dll", "int RtwqCreateAsyncResult(void*, void*, void*, void*)")
# 呼び出し: RtwqCreateAsyncResult(appObject, callback, appState, asyncResult)
# appObject : IUnknown* -> "void*"
# callback : IRtwqAsyncCallback* -> "void*"
# appState : IUnknown* -> "void*"
# asyncResult : IRtwqAsyncResult** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "rtworkq" fn RtwqCreateAsyncResult(
    appObject: ?*anyopaque, // IUnknown*
    callback: ?*anyopaque, // IRtwqAsyncCallback*
    appState: ?*anyopaque, // IUnknown*
    asyncResult: ?*anyopaque // IRtwqAsyncResult** out
) callconv(std.os.windows.WINAPI) i32;
proc RtwqCreateAsyncResult(
    appObject: pointer,  # IUnknown*
    callback: pointer,  # IRtwqAsyncCallback*
    appState: pointer,  # IUnknown*
    asyncResult: pointer  # IRtwqAsyncResult** out
): int32 {.importc: "RtwqCreateAsyncResult", stdcall, dynlib: "RTWorkQ.dll".}
pragma(lib, "rtworkq");
extern(Windows)
int RtwqCreateAsyncResult(
    void* appObject,   // IUnknown*
    void* callback,   // IRtwqAsyncCallback*
    void* appState,   // IUnknown*
    void* asyncResult   // IRtwqAsyncResult** out
);
ccall((:RtwqCreateAsyncResult, "RTWorkQ.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
      appObject, callback, appState, asyncResult)
# appObject : IUnknown* -> Ptr{Cvoid}
# callback : IRtwqAsyncCallback* -> Ptr{Cvoid}
# appState : IUnknown* -> Ptr{Cvoid}
# asyncResult : IRtwqAsyncResult** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t RtwqCreateAsyncResult(
    void* appObject,
    void* callback,
    void* appState,
    void* asyncResult);
]]
local rtworkq = ffi.load("rtworkq")
-- rtworkq.RtwqCreateAsyncResult(appObject, callback, appState, asyncResult)
-- appObject : IUnknown*
-- callback : IRtwqAsyncCallback*
-- appState : IUnknown*
-- asyncResult : IRtwqAsyncResult** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RTWorkQ.dll');
const RtwqCreateAsyncResult = lib.func('__stdcall', 'RtwqCreateAsyncResult', 'int32_t', ['void *', 'void *', 'void *', 'void *']);
// RtwqCreateAsyncResult(appObject, callback, appState, asyncResult)
// appObject : IUnknown* -> 'void *'
// callback : IRtwqAsyncCallback* -> 'void *'
// appState : IUnknown* -> 'void *'
// asyncResult : IRtwqAsyncResult** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RTWorkQ.dll", {
  RtwqCreateAsyncResult: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.RtwqCreateAsyncResult(appObject, callback, appState, asyncResult)
// appObject : IUnknown* -> "pointer"
// callback : IRtwqAsyncCallback* -> "pointer"
// appState : IUnknown* -> "pointer"
// asyncResult : IRtwqAsyncResult** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RtwqCreateAsyncResult(
    void* appObject,
    void* callback,
    void* appState,
    void* asyncResult);
C, "RTWorkQ.dll");
// $ffi->RtwqCreateAsyncResult(appObject, callback, appState, asyncResult);
// appObject : IUnknown*
// callback : IRtwqAsyncCallback*
// appState : IUnknown*
// asyncResult : IRtwqAsyncResult** 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 Rtworkq extends StdCallLibrary {
    Rtworkq INSTANCE = Native.load("rtworkq", Rtworkq.class);
    int RtwqCreateAsyncResult(
        Pointer appObject,   // IUnknown*
        Pointer callback,   // IRtwqAsyncCallback*
        Pointer appState,   // IUnknown*
        Pointer asyncResult   // IRtwqAsyncResult** out
    );
}
@[Link("rtworkq")]
lib LibRTWorkQ
  fun RtwqCreateAsyncResult = RtwqCreateAsyncResult(
    appObject : Void*,   # IUnknown*
    callback : Void*,   # IRtwqAsyncCallback*
    appState : Void*,   # IUnknown*
    asyncResult : Void*   # IRtwqAsyncResult** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RtwqCreateAsyncResultNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef RtwqCreateAsyncResultDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final RtwqCreateAsyncResult = DynamicLibrary.open('RTWorkQ.dll')
    .lookupFunction<RtwqCreateAsyncResultNative, RtwqCreateAsyncResultDart>('RtwqCreateAsyncResult');
// appObject : IUnknown* -> Pointer<Void>
// callback : IRtwqAsyncCallback* -> Pointer<Void>
// appState : IUnknown* -> Pointer<Void>
// asyncResult : IRtwqAsyncResult** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RtwqCreateAsyncResult(
  appObject: Pointer;   // IUnknown*
  callback: Pointer;   // IRtwqAsyncCallback*
  appState: Pointer;   // IUnknown*
  asyncResult: Pointer   // IRtwqAsyncResult** out
): Integer; stdcall;
  external 'RTWorkQ.dll' name 'RtwqCreateAsyncResult';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RtwqCreateAsyncResult"
  c_RtwqCreateAsyncResult :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- appObject : IUnknown* -> Ptr ()
-- callback : IRtwqAsyncCallback* -> Ptr ()
-- appState : IUnknown* -> Ptr ()
-- asyncResult : IRtwqAsyncResult** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rtwqcreateasyncresult =
  foreign "RtwqCreateAsyncResult"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* appObject : IUnknown* -> (ptr void) *)
(* callback : IRtwqAsyncCallback* -> (ptr void) *)
(* appState : IUnknown* -> (ptr void) *)
(* asyncResult : IRtwqAsyncResult** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rtworkq (t "RTWorkQ.dll"))
(cffi:use-foreign-library rtworkq)

(cffi:defcfun ("RtwqCreateAsyncResult" rtwq-create-async-result :convention :stdcall) :int32
  (app-object :pointer)   ; IUnknown*
  (callback :pointer)   ; IRtwqAsyncCallback*
  (app-state :pointer)   ; IUnknown*
  (async-result :pointer))   ; IRtwqAsyncResult** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RtwqCreateAsyncResult = Win32::API::More->new('RTWorkQ',
    'int RtwqCreateAsyncResult(LPVOID appObject, LPVOID callback, LPVOID appState, LPVOID asyncResult)');
# my $ret = $RtwqCreateAsyncResult->Call($appObject, $callback, $appState, $asyncResult);
# appObject : IUnknown* -> LPVOID
# callback : IRtwqAsyncCallback* -> LPVOID
# appState : IUnknown* -> LPVOID
# asyncResult : IRtwqAsyncResult** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型