Win32 API 日本語リファレンス
ホームMedia › timeGetDevCaps

timeGetDevCaps

関数
タイマーデバイスがサポートする分解能の範囲を取得する。
DLLWINMM.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD timeGetDevCaps(
    TIMECAPS* ptc,
    DWORD cbtc
);

パラメーター

名前方向
ptcTIMECAPS*out
cbtcDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD timeGetDevCaps(
    TIMECAPS* ptc,
    DWORD cbtc
);
[DllImport("WINMM.dll", ExactSpelling = true)]
static extern uint timeGetDevCaps(
    IntPtr ptc,   // TIMECAPS* out
    uint cbtc   // DWORD
);
<DllImport("WINMM.dll", ExactSpelling:=True)>
Public Shared Function timeGetDevCaps(
    ptc As IntPtr,   ' TIMECAPS* out
    cbtc As UInteger   ' DWORD
) As UInteger
End Function
' ptc : TIMECAPS* out
' cbtc : DWORD
Declare PtrSafe Function timeGetDevCaps Lib "winmm" ( _
    ByVal ptc As LongPtr, _
    ByVal cbtc As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

timeGetDevCaps = ctypes.windll.winmm.timeGetDevCaps
timeGetDevCaps.restype = wintypes.DWORD
timeGetDevCaps.argtypes = [
    ctypes.c_void_p,  # ptc : TIMECAPS* out
    wintypes.DWORD,  # cbtc : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	winmm = windows.NewLazySystemDLL("WINMM.dll")
	proctimeGetDevCaps = winmm.NewProc("timeGetDevCaps")
)

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