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

RtwqRegisterPlatformWithMMCSS

関数
RTWQプラットフォームをMMCSSタスクに登録する。
DLLRTWorkQ.dll呼出規約winapi対応OSWindows 8.1 以降

シグネチャ

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

HRESULT RtwqRegisterPlatformWithMMCSS(
    LPCWSTR usageClass,
    DWORD* taskId,
    INT lPriority
);

パラメーター

名前方向
usageClassLPCWSTRin
taskIdDWORD*inout
lPriorityINTin

戻り値の型: HRESULT

各言語での呼び出し定義

// 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // HRESULT
function 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)。