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

RtwqAllocateWorkQueue

関数
指定の種類の作業キューを割り当てる。
DLLRTWorkQ.dll呼出規約winapi対応OSWindows 8.1 以降

シグネチャ

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

HRESULT RtwqAllocateWorkQueue(
    RTWQ_WORKQUEUE_TYPE WorkQueueType,
    DWORD* workQueueId
);

パラメーター

名前方向
WorkQueueTypeRTWQ_WORKQUEUE_TYPEin
workQueueIdDWORD*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT RtwqAllocateWorkQueue(
    RTWQ_WORKQUEUE_TYPE WorkQueueType,
    DWORD* workQueueId
);
[DllImport("RTWorkQ.dll", ExactSpelling = true)]
static extern int RtwqAllocateWorkQueue(
    int WorkQueueType,   // RTWQ_WORKQUEUE_TYPE
    out uint workQueueId   // DWORD* out
);
<DllImport("RTWorkQ.dll", ExactSpelling:=True)>
Public Shared Function RtwqAllocateWorkQueue(
    WorkQueueType As Integer,   ' RTWQ_WORKQUEUE_TYPE
    <Out> ByRef workQueueId As UInteger   ' DWORD* out
) As Integer
End Function
' WorkQueueType : RTWQ_WORKQUEUE_TYPE
' workQueueId : DWORD* out
Declare PtrSafe Function RtwqAllocateWorkQueue Lib "rtworkq" ( _
    ByVal WorkQueueType As Long, _
    ByRef workQueueId As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtwqAllocateWorkQueue = ctypes.windll.rtworkq.RtwqAllocateWorkQueue
RtwqAllocateWorkQueue.restype = ctypes.c_int
RtwqAllocateWorkQueue.argtypes = [
    ctypes.c_int,  # WorkQueueType : RTWQ_WORKQUEUE_TYPE
    ctypes.POINTER(wintypes.DWORD),  # workQueueId : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rtworkq = windows.NewLazySystemDLL("RTWorkQ.dll")
	procRtwqAllocateWorkQueue = rtworkq.NewProc("RtwqAllocateWorkQueue")
)

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