ホーム › System.Threading › RtwqRegisterPlatformWithMMCSS
RtwqRegisterPlatformWithMMCSS
関数RTWQプラットフォームをMMCSSタスクに登録する。
シグネチャ
// RTWorkQ.dll
#include <windows.h>
HRESULT RtwqRegisterPlatformWithMMCSS(
LPCWSTR usageClass,
DWORD* taskId,
INT lPriority
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| usageClass | LPCWSTR | in | MMCSS タスクの名前。 |
| taskId | DWORD* | inout | MMCSS タスク識別子。入力時には、既存の MMCSS タスクグループ ID を指定するか、新しいタスクグループを作成するには値 0 を使用します。出力時には、実際のタスクグループ ID を受け取ります。 |
| lPriority | INT | in | 作業キュースレッドの基本優先度。 |
戻り値の型: HRESULT
公式ドキュメント
標準のプラットフォーム作業キューを Multimedia Class Scheduler Service (MMCSS) に登録します。
戻り値
この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// RTWorkQ.dll
#include <windows.h>
HRESULT RtwqRegisterPlatformWithMMCSS(
LPCWSTR usageClass,
DWORD* taskId,
INT lPriority
);[DllImport("RTWorkQ.dll", ExactSpelling = true)]
static extern int RtwqRegisterPlatformWithMMCSS(
[MarshalAs(UnmanagedType.LPWStr)] string usageClass, // LPCWSTR
ref uint taskId, // DWORD* in/out
int lPriority // INT
);<DllImport("RTWorkQ.dll", ExactSpelling:=True)>
Public Shared Function RtwqRegisterPlatformWithMMCSS(
<MarshalAs(UnmanagedType.LPWStr)> usageClass As String, ' LPCWSTR
ByRef taskId As UInteger, ' DWORD* in/out
lPriority As Integer ' INT
) As Integer
End Function' usageClass : LPCWSTR
' taskId : DWORD* in/out
' lPriority : INT
Declare PtrSafe Function RtwqRegisterPlatformWithMMCSS Lib "rtworkq" ( _
ByVal usageClass As LongPtr, _
ByRef taskId As Long, _
ByVal lPriority As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RtwqRegisterPlatformWithMMCSS = ctypes.windll.rtworkq.RtwqRegisterPlatformWithMMCSS
RtwqRegisterPlatformWithMMCSS.restype = ctypes.c_int
RtwqRegisterPlatformWithMMCSS.argtypes = [
wintypes.LPCWSTR, # usageClass : LPCWSTR
ctypes.POINTER(wintypes.DWORD), # taskId : DWORD* in/out
ctypes.c_int, # lPriority : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RTWorkQ.dll')
RtwqRegisterPlatformWithMMCSS = Fiddle::Function.new(
lib['RtwqRegisterPlatformWithMMCSS'],
[
Fiddle::TYPE_VOIDP, # usageClass : LPCWSTR
Fiddle::TYPE_VOIDP, # taskId : DWORD* in/out
Fiddle::TYPE_INT, # lPriority : INT
],
Fiddle::TYPE_INT)#[link(name = "rtworkq")]
extern "system" {
fn RtwqRegisterPlatformWithMMCSS(
usageClass: *const u16, // LPCWSTR
taskId: *mut u32, // DWORD* in/out
lPriority: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RTWorkQ.dll")]
public static extern int RtwqRegisterPlatformWithMMCSS([MarshalAs(UnmanagedType.LPWStr)] string usageClass, ref uint taskId, int lPriority);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RTWorkQ_RtwqRegisterPlatformWithMMCSS' -Namespace Win32 -PassThru
# $api::RtwqRegisterPlatformWithMMCSS(usageClass, taskId, lPriority)#uselib "RTWorkQ.dll"
#func global RtwqRegisterPlatformWithMMCSS "RtwqRegisterPlatformWithMMCSS" sptr, sptr, sptr
; RtwqRegisterPlatformWithMMCSS usageClass, varptr(taskId), lPriority ; 戻り値は stat
; usageClass : LPCWSTR -> "sptr"
; taskId : DWORD* in/out -> "sptr"
; lPriority : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RTWorkQ.dll" #cfunc global RtwqRegisterPlatformWithMMCSS "RtwqRegisterPlatformWithMMCSS" wstr, var, int ; res = RtwqRegisterPlatformWithMMCSS(usageClass, taskId, lPriority) ; usageClass : LPCWSTR -> "wstr" ; taskId : DWORD* in/out -> "var" ; lPriority : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RTWorkQ.dll" #cfunc global RtwqRegisterPlatformWithMMCSS "RtwqRegisterPlatformWithMMCSS" wstr, sptr, int ; res = RtwqRegisterPlatformWithMMCSS(usageClass, varptr(taskId), lPriority) ; usageClass : LPCWSTR -> "wstr" ; taskId : DWORD* in/out -> "sptr" ; lPriority : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT RtwqRegisterPlatformWithMMCSS(LPCWSTR usageClass, DWORD* taskId, INT lPriority) #uselib "RTWorkQ.dll" #cfunc global RtwqRegisterPlatformWithMMCSS "RtwqRegisterPlatformWithMMCSS" wstr, var, int ; res = RtwqRegisterPlatformWithMMCSS(usageClass, taskId, lPriority) ; usageClass : LPCWSTR -> "wstr" ; taskId : DWORD* in/out -> "var" ; lPriority : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT RtwqRegisterPlatformWithMMCSS(LPCWSTR usageClass, DWORD* taskId, INT lPriority) #uselib "RTWorkQ.dll" #cfunc global RtwqRegisterPlatformWithMMCSS "RtwqRegisterPlatformWithMMCSS" wstr, intptr, int ; res = RtwqRegisterPlatformWithMMCSS(usageClass, varptr(taskId), lPriority) ; usageClass : LPCWSTR -> "wstr" ; taskId : DWORD* in/out -> "intptr" ; lPriority : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rtworkq = windows.NewLazySystemDLL("RTWorkQ.dll")
procRtwqRegisterPlatformWithMMCSS = rtworkq.NewProc("RtwqRegisterPlatformWithMMCSS")
)
// usageClass (LPCWSTR), taskId (DWORD* in/out), lPriority (INT)
r1, _, err := procRtwqRegisterPlatformWithMMCSS.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(usageClass))),
uintptr(taskId),
uintptr(lPriority),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RtwqRegisterPlatformWithMMCSS(
usageClass: PWideChar; // LPCWSTR
taskId: Pointer; // DWORD* in/out
lPriority: Integer // INT
): Integer; stdcall;
external 'RTWorkQ.dll' name 'RtwqRegisterPlatformWithMMCSS';result := DllCall("RTWorkQ\RtwqRegisterPlatformWithMMCSS"
, "WStr", usageClass ; LPCWSTR
, "Ptr", taskId ; DWORD* in/out
, "Int", lPriority ; INT
, "Int") ; return: HRESULT●RtwqRegisterPlatformWithMMCSS(usageClass, taskId, lPriority) = DLL("RTWorkQ.dll", "int RtwqRegisterPlatformWithMMCSS(char*, void*, int)")
# 呼び出し: RtwqRegisterPlatformWithMMCSS(usageClass, taskId, lPriority)
# usageClass : LPCWSTR -> "char*"
# taskId : DWORD* in/out -> "void*"
# lPriority : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rtworkq" fn RtwqRegisterPlatformWithMMCSS(
usageClass: [*c]const u16, // LPCWSTR
taskId: [*c]u32, // DWORD* in/out
lPriority: i32 // INT
) callconv(std.os.windows.WINAPI) i32;proc RtwqRegisterPlatformWithMMCSS(
usageClass: WideCString, # LPCWSTR
taskId: ptr uint32, # DWORD* in/out
lPriority: int32 # INT
): int32 {.importc: "RtwqRegisterPlatformWithMMCSS", stdcall, dynlib: "RTWorkQ.dll".}pragma(lib, "rtworkq");
extern(Windows)
int RtwqRegisterPlatformWithMMCSS(
const(wchar)* usageClass, // LPCWSTR
uint* taskId, // DWORD* in/out
int lPriority // INT
);ccall((:RtwqRegisterPlatformWithMMCSS, "RTWorkQ.dll"), stdcall, Int32,
(Cwstring, Ptr{UInt32}, Int32),
usageClass, taskId, lPriority)
# usageClass : LPCWSTR -> Cwstring
# taskId : DWORD* in/out -> Ptr{UInt32}
# lPriority : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RtwqRegisterPlatformWithMMCSS(
const uint16_t* usageClass,
uint32_t* taskId,
int32_t lPriority);
]]
local rtworkq = ffi.load("rtworkq")
-- rtworkq.RtwqRegisterPlatformWithMMCSS(usageClass, taskId, lPriority)
-- usageClass : LPCWSTR
-- taskId : DWORD* in/out
-- lPriority : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RTWorkQ.dll');
const RtwqRegisterPlatformWithMMCSS = lib.func('__stdcall', 'RtwqRegisterPlatformWithMMCSS', 'int32_t', ['str16', 'uint32_t *', 'int32_t']);
// RtwqRegisterPlatformWithMMCSS(usageClass, taskId, lPriority)
// usageClass : LPCWSTR -> 'str16'
// taskId : DWORD* in/out -> 'uint32_t *'
// lPriority : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RTWorkQ.dll", {
RtwqRegisterPlatformWithMMCSS: { parameters: ["buffer", "pointer", "i32"], result: "i32" },
});
// lib.symbols.RtwqRegisterPlatformWithMMCSS(usageClass, taskId, lPriority)
// usageClass : LPCWSTR -> "buffer"
// taskId : DWORD* in/out -> "pointer"
// lPriority : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RtwqRegisterPlatformWithMMCSS(
const uint16_t* usageClass,
uint32_t* taskId,
int32_t lPriority);
C, "RTWorkQ.dll");
// $ffi->RtwqRegisterPlatformWithMMCSS(usageClass, taskId, lPriority);
// usageClass : LPCWSTR
// taskId : DWORD* in/out
// lPriority : INT
// 構造体/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 RtwqRegisterPlatformWithMMCSS(
WString usageClass, // LPCWSTR
IntByReference taskId, // DWORD* in/out
int lPriority // INT
);
}@[Link("rtworkq")]
lib LibRTWorkQ
fun RtwqRegisterPlatformWithMMCSS = RtwqRegisterPlatformWithMMCSS(
usageClass : UInt16*, # LPCWSTR
taskId : UInt32*, # DWORD* in/out
lPriority : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RtwqRegisterPlatformWithMMCSSNative = Int32 Function(Pointer<Utf16>, Pointer<Uint32>, Int32);
typedef RtwqRegisterPlatformWithMMCSSDart = int Function(Pointer<Utf16>, Pointer<Uint32>, int);
final RtwqRegisterPlatformWithMMCSS = DynamicLibrary.open('RTWorkQ.dll')
.lookupFunction<RtwqRegisterPlatformWithMMCSSNative, RtwqRegisterPlatformWithMMCSSDart>('RtwqRegisterPlatformWithMMCSS');
// usageClass : LPCWSTR -> Pointer<Utf16>
// taskId : DWORD* in/out -> Pointer<Uint32>
// lPriority : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RtwqRegisterPlatformWithMMCSS(
usageClass: PWideChar; // LPCWSTR
taskId: Pointer; // DWORD* in/out
lPriority: Integer // INT
): Integer; stdcall;
external 'RTWorkQ.dll' name 'RtwqRegisterPlatformWithMMCSS';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RtwqRegisterPlatformWithMMCSS"
c_RtwqRegisterPlatformWithMMCSS :: CWString -> Ptr Word32 -> Int32 -> IO Int32
-- usageClass : LPCWSTR -> CWString
-- taskId : DWORD* in/out -> Ptr Word32
-- lPriority : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rtwqregisterplatformwithmmcss =
foreign "RtwqRegisterPlatformWithMMCSS"
((ptr uint16_t) @-> (ptr uint32_t) @-> int32_t @-> returning int32_t)
(* usageClass : LPCWSTR -> (ptr uint16_t) *)
(* taskId : DWORD* in/out -> (ptr uint32_t) *)
(* lPriority : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rtworkq (t "RTWorkQ.dll"))
(cffi:use-foreign-library rtworkq)
(cffi:defcfun ("RtwqRegisterPlatformWithMMCSS" rtwq-register-platform-with-mmcss :convention :stdcall) :int32
(usage-class (:string :encoding :utf-16le)) ; LPCWSTR
(task-id :pointer) ; DWORD* in/out
(l-priority :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RtwqRegisterPlatformWithMMCSS = Win32::API::More->new('RTWorkQ',
'int RtwqRegisterPlatformWithMMCSS(LPCWSTR usageClass, LPVOID taskId, int lPriority)');
# my $ret = $RtwqRegisterPlatformWithMMCSS->Call($usageClass, $taskId, $lPriority);
# usageClass : LPCWSTR -> LPCWSTR
# taskId : DWORD* in/out -> LPVOID
# lPriority : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。