timeGetDevCaps
関数タイマーデバイスがサポートする分解能の範囲を取得する。
シグネチャ
// WINMM.dll
#include <windows.h>
DWORD timeGetDevCaps(
TIMECAPS* ptc,
DWORD cbtc
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ptc | TIMECAPS* | out | タイマーデバイスの能力(最小・最大分解能)を受け取るTIMECAPS構造体へのポインター。 |
| cbtc | DWORD | in | ptcが指すTIMECAPS構造体のバイトサイズ。 |
戻り値の型: 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 方式にも切替可。#uselib "WINMM.dll" #cfunc global timeGetDevCaps "timeGetDevCaps" sptr, int ; res = timeGetDevCaps(varptr(ptc), cbtc) ; ptc : TIMECAPS* out -> "sptr" ; cbtc : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; DWORD timeGetDevCaps(TIMECAPS* ptc, DWORD cbtc) #uselib "WINMM.dll" #cfunc global timeGetDevCaps "timeGetDevCaps" intptr, int ; res = timeGetDevCaps(varptr(ptc), cbtc) ; ptc : TIMECAPS* out -> "intptr" ; cbtc : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。const std = @import("std");
extern "winmm" fn timeGetDevCaps(
ptc: [*c]TIMECAPS, // TIMECAPS* out
cbtc: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc timeGetDevCaps(
ptc: ptr TIMECAPS, # TIMECAPS* out
cbtc: uint32 # DWORD
): uint32 {.importc: "timeGetDevCaps", stdcall, dynlib: "WINMM.dll".}pragma(lib, "winmm");
extern(Windows)
uint timeGetDevCaps(
TIMECAPS* ptc, // TIMECAPS* out
uint cbtc // DWORD
);ccall((:timeGetDevCaps, "WINMM.dll"), stdcall, UInt32,
(Ptr{TIMECAPS}, UInt32),
ptc, cbtc)
# ptc : TIMECAPS* out -> Ptr{TIMECAPS}
# cbtc : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t timeGetDevCaps(
void* ptc,
uint32_t cbtc);
]]
local winmm = ffi.load("winmm")
-- winmm.timeGetDevCaps(ptc, cbtc)
-- ptc : TIMECAPS* out
-- cbtc : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WINMM.dll');
const timeGetDevCaps = lib.func('__stdcall', 'timeGetDevCaps', 'uint32_t', ['void *', 'uint32_t']);
// timeGetDevCaps(ptc, cbtc)
// ptc : TIMECAPS* out -> 'void *'
// cbtc : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WINMM.dll", {
timeGetDevCaps: { parameters: ["pointer", "u32"], result: "u32" },
});
// lib.symbols.timeGetDevCaps(ptc, cbtc)
// ptc : TIMECAPS* out -> "pointer"
// cbtc : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t timeGetDevCaps(
void* ptc,
uint32_t cbtc);
C, "WINMM.dll");
// $ffi->timeGetDevCaps(ptc, cbtc);
// ptc : TIMECAPS* out
// cbtc : DWORD
// 構造体/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 Winmm extends StdCallLibrary {
Winmm INSTANCE = Native.load("winmm", Winmm.class);
int timeGetDevCaps(
Pointer ptc, // TIMECAPS* out
int cbtc // DWORD
);
}@[Link("winmm")]
lib LibWINMM
fun timeGetDevCaps = timeGetDevCaps(
ptc : TIMECAPS*, # TIMECAPS* out
cbtc : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef timeGetDevCapsNative = Uint32 Function(Pointer<Void>, Uint32);
typedef timeGetDevCapsDart = int Function(Pointer<Void>, int);
final timeGetDevCaps = DynamicLibrary.open('WINMM.dll')
.lookupFunction<timeGetDevCapsNative, timeGetDevCapsDart>('timeGetDevCaps');
// ptc : TIMECAPS* out -> Pointer<Void>
// cbtc : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function timeGetDevCaps(
ptc: Pointer; // TIMECAPS* out
cbtc: DWORD // DWORD
): DWORD; stdcall;
external 'WINMM.dll' name 'timeGetDevCaps';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "timeGetDevCaps"
c_timeGetDevCaps :: Ptr () -> Word32 -> IO Word32
-- ptc : TIMECAPS* out -> Ptr ()
-- cbtc : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let timegetdevcaps =
foreign "timeGetDevCaps"
((ptr void) @-> uint32_t @-> returning uint32_t)
(* ptc : TIMECAPS* out -> (ptr void) *)
(* cbtc : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winmm (t "WINMM.dll"))
(cffi:use-foreign-library winmm)
(cffi:defcfun ("timeGetDevCaps" time-get-dev-caps :convention :stdcall) :uint32
(ptc :pointer) ; TIMECAPS* out
(cbtc :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $timeGetDevCaps = Win32::API::More->new('WINMM',
'DWORD timeGetDevCaps(LPVOID ptc, DWORD cbtc)');
# my $ret = $timeGetDevCaps->Call($ptc, $cbtc);
# ptc : TIMECAPS* out -> LPVOID
# cbtc : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型