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

AvSetMmThreadCharacteristicsW

関数
マルチメディア処理向けにスレッド特性を登録する(Unicode版)。
DLLAVRT.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

// AVRT.dll  (Unicode / -W)
#include <windows.h>

AVRT_TASK_HANDLE AvSetMmThreadCharacteristicsW(
    LPCWSTR TaskName,
    DWORD* TaskIndex
);

パラメーター

名前方向
TaskNameLPCWSTRin
TaskIndexDWORD*inout

戻り値の型: AVRT_TASK_HANDLE

各言語での呼び出し定義

// AVRT.dll  (Unicode / -W)
#include <windows.h>

AVRT_TASK_HANDLE AvSetMmThreadCharacteristicsW(
    LPCWSTR TaskName,
    DWORD* TaskIndex
);
[DllImport("AVRT.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern AVRT_TASK_HANDLE AvSetMmThreadCharacteristicsW(
    [MarshalAs(UnmanagedType.LPWStr)] string TaskName,   // LPCWSTR
    ref uint TaskIndex   // DWORD* in/out
);
<DllImport("AVRT.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AvSetMmThreadCharacteristicsW(
    <MarshalAs(UnmanagedType.LPWStr)> TaskName As String,   ' LPCWSTR
    ByRef TaskIndex As UInteger   ' DWORD* in/out
) As AVRT_TASK_HANDLE
End Function
' TaskName : LPCWSTR
' TaskIndex : DWORD* in/out
Declare PtrSafe Function AvSetMmThreadCharacteristicsW Lib "avrt" ( _
    ByVal TaskName As LongPtr, _
    ByRef TaskIndex As Long) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AvSetMmThreadCharacteristicsW = ctypes.windll.avrt.AvSetMmThreadCharacteristicsW
AvSetMmThreadCharacteristicsW.restype = ctypes.c_void_p
AvSetMmThreadCharacteristicsW.argtypes = [
    wintypes.LPCWSTR,  # TaskName : LPCWSTR
    ctypes.POINTER(wintypes.DWORD),  # TaskIndex : DWORD* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('AVRT.dll')
AvSetMmThreadCharacteristicsW = Fiddle::Function.new(
  lib['AvSetMmThreadCharacteristicsW'],
  [
    Fiddle::TYPE_VOIDP,  # TaskName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # TaskIndex : DWORD* in/out
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "avrt")]
extern "system" {
    fn AvSetMmThreadCharacteristicsW(
        TaskName: *const u16,  // LPCWSTR
        TaskIndex: *mut u32  // DWORD* in/out
    ) -> AVRT_TASK_HANDLE;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("AVRT.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern AVRT_TASK_HANDLE AvSetMmThreadCharacteristicsW([MarshalAs(UnmanagedType.LPWStr)] string TaskName, ref uint TaskIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'AVRT_AvSetMmThreadCharacteristicsW' -Namespace Win32 -PassThru
# $api::AvSetMmThreadCharacteristicsW(TaskName, TaskIndex)
#uselib "AVRT.dll"
#func global AvSetMmThreadCharacteristicsW "AvSetMmThreadCharacteristicsW" wptr, wptr
; AvSetMmThreadCharacteristicsW TaskName, varptr(TaskIndex)   ; 戻り値は stat
; TaskName : LPCWSTR -> "wptr"
; TaskIndex : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "AVRT.dll"
#cfunc global AvSetMmThreadCharacteristicsW "AvSetMmThreadCharacteristicsW" wstr, var
; res = AvSetMmThreadCharacteristicsW(TaskName, TaskIndex)
; TaskName : LPCWSTR -> "wstr"
; TaskIndex : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; AVRT_TASK_HANDLE AvSetMmThreadCharacteristicsW(LPCWSTR TaskName, DWORD* TaskIndex)
#uselib "AVRT.dll"
#cfunc global AvSetMmThreadCharacteristicsW "AvSetMmThreadCharacteristicsW" wstr, var
; res = AvSetMmThreadCharacteristicsW(TaskName, TaskIndex)
; TaskName : LPCWSTR -> "wstr"
; TaskIndex : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	avrt = windows.NewLazySystemDLL("AVRT.dll")
	procAvSetMmThreadCharacteristicsW = avrt.NewProc("AvSetMmThreadCharacteristicsW")
)

// TaskName (LPCWSTR), TaskIndex (DWORD* in/out)
r1, _, err := procAvSetMmThreadCharacteristicsW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TaskName))),
	uintptr(TaskIndex),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // AVRT_TASK_HANDLE
function AvSetMmThreadCharacteristicsW(
  TaskName: PWideChar;   // LPCWSTR
  TaskIndex: Pointer   // DWORD* in/out
): AVRT_TASK_HANDLE; stdcall;
  external 'AVRT.dll' name 'AvSetMmThreadCharacteristicsW';
result := DllCall("AVRT\AvSetMmThreadCharacteristicsW"
    , "WStr", TaskName   ; LPCWSTR
    , "Ptr", TaskIndex   ; DWORD* in/out
    , "Ptr")   ; return: AVRT_TASK_HANDLE
●AvSetMmThreadCharacteristicsW(TaskName, TaskIndex) = DLL("AVRT.dll", "void* AvSetMmThreadCharacteristicsW(char*, void*)")
# 呼び出し: AvSetMmThreadCharacteristicsW(TaskName, TaskIndex)
# TaskName : LPCWSTR -> "char*"
# TaskIndex : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。