Win32 API 日本語リファレンス
ホームGraphics.Dwm › DwmModifyPreviousDxFrameDuration

DwmModifyPreviousDxFrameDuration

関数
前のDirectXフレームの表示継続時間を変更する。
DLLdwmapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT DwmModifyPreviousDxFrameDuration(
    HWND hwnd,
    INT cRefreshes,
    BOOL fRelative
);

パラメーター

名前方向説明
hwndHWNDinフレーム表示時間を変更する対象のウィンドウハンドル。
cRefreshesINTin前フレームの表示を継続するリフレッシュ回数を指定する。
fRelativeBOOLin値を相対指定とするか絶対指定とするかを示す真偽値。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DwmModifyPreviousDxFrameDuration(
    HWND hwnd,
    INT cRefreshes,
    BOOL fRelative
);
[DllImport("dwmapi.dll", ExactSpelling = true)]
static extern int DwmModifyPreviousDxFrameDuration(
    IntPtr hwnd,   // HWND
    int cRefreshes,   // INT
    bool fRelative   // BOOL
);
<DllImport("dwmapi.dll", ExactSpelling:=True)>
Public Shared Function DwmModifyPreviousDxFrameDuration(
    hwnd As IntPtr,   ' HWND
    cRefreshes As Integer,   ' INT
    fRelative As Boolean   ' BOOL
) As Integer
End Function
' hwnd : HWND
' cRefreshes : INT
' fRelative : BOOL
Declare PtrSafe Function DwmModifyPreviousDxFrameDuration Lib "dwmapi" ( _
    ByVal hwnd As LongPtr, _
    ByVal cRefreshes As Long, _
    ByVal fRelative As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DwmModifyPreviousDxFrameDuration = ctypes.windll.dwmapi.DwmModifyPreviousDxFrameDuration
DwmModifyPreviousDxFrameDuration.restype = ctypes.c_int
DwmModifyPreviousDxFrameDuration.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    ctypes.c_int,  # cRefreshes : INT
    wintypes.BOOL,  # fRelative : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dwmapi.dll')
DwmModifyPreviousDxFrameDuration = Fiddle::Function.new(
  lib['DwmModifyPreviousDxFrameDuration'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND
    Fiddle::TYPE_INT,  # cRefreshes : INT
    Fiddle::TYPE_INT,  # fRelative : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "dwmapi")]
extern "system" {
    fn DwmModifyPreviousDxFrameDuration(
        hwnd: *mut core::ffi::c_void,  // HWND
        cRefreshes: i32,  // INT
        fRelative: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("dwmapi.dll")]
public static extern int DwmModifyPreviousDxFrameDuration(IntPtr hwnd, int cRefreshes, bool fRelative);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dwmapi_DwmModifyPreviousDxFrameDuration' -Namespace Win32 -PassThru
# $api::DwmModifyPreviousDxFrameDuration(hwnd, cRefreshes, fRelative)
#uselib "dwmapi.dll"
#func global DwmModifyPreviousDxFrameDuration "DwmModifyPreviousDxFrameDuration" sptr, sptr, sptr
; DwmModifyPreviousDxFrameDuration hwnd, cRefreshes, fRelative   ; 戻り値は stat
; hwnd : HWND -> "sptr"
; cRefreshes : INT -> "sptr"
; fRelative : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "dwmapi.dll"
#cfunc global DwmModifyPreviousDxFrameDuration "DwmModifyPreviousDxFrameDuration" sptr, int, int
; res = DwmModifyPreviousDxFrameDuration(hwnd, cRefreshes, fRelative)
; hwnd : HWND -> "sptr"
; cRefreshes : INT -> "int"
; fRelative : BOOL -> "int"
; HRESULT DwmModifyPreviousDxFrameDuration(HWND hwnd, INT cRefreshes, BOOL fRelative)
#uselib "dwmapi.dll"
#cfunc global DwmModifyPreviousDxFrameDuration "DwmModifyPreviousDxFrameDuration" intptr, int, int
; res = DwmModifyPreviousDxFrameDuration(hwnd, cRefreshes, fRelative)
; hwnd : HWND -> "intptr"
; cRefreshes : INT -> "int"
; fRelative : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dwmapi = windows.NewLazySystemDLL("dwmapi.dll")
	procDwmModifyPreviousDxFrameDuration = dwmapi.NewProc("DwmModifyPreviousDxFrameDuration")
)

// hwnd (HWND), cRefreshes (INT), fRelative (BOOL)
r1, _, err := procDwmModifyPreviousDxFrameDuration.Call(
	uintptr(hwnd),
	uintptr(cRefreshes),
	uintptr(fRelative),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function DwmModifyPreviousDxFrameDuration(
  hwnd: THandle;   // HWND
  cRefreshes: Integer;   // INT
  fRelative: BOOL   // BOOL
): Integer; stdcall;
  external 'dwmapi.dll' name 'DwmModifyPreviousDxFrameDuration';
result := DllCall("dwmapi\DwmModifyPreviousDxFrameDuration"
    , "Ptr", hwnd   ; HWND
    , "Int", cRefreshes   ; INT
    , "Int", fRelative   ; BOOL
    , "Int")   ; return: HRESULT
●DwmModifyPreviousDxFrameDuration(hwnd, cRefreshes, fRelative) = DLL("dwmapi.dll", "int DwmModifyPreviousDxFrameDuration(void*, int, bool)")
# 呼び出し: DwmModifyPreviousDxFrameDuration(hwnd, cRefreshes, fRelative)
# hwnd : HWND -> "void*"
# cRefreshes : INT -> "int"
# fRelative : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "dwmapi" fn DwmModifyPreviousDxFrameDuration(
    hwnd: ?*anyopaque, // HWND
    cRefreshes: i32, // INT
    fRelative: i32 // BOOL
) callconv(std.os.windows.WINAPI) i32;
proc DwmModifyPreviousDxFrameDuration(
    hwnd: pointer,  # HWND
    cRefreshes: int32,  # INT
    fRelative: int32  # BOOL
): int32 {.importc: "DwmModifyPreviousDxFrameDuration", stdcall, dynlib: "dwmapi.dll".}
pragma(lib, "dwmapi");
extern(Windows)
int DwmModifyPreviousDxFrameDuration(
    void* hwnd,   // HWND
    int cRefreshes,   // INT
    int fRelative   // BOOL
);
ccall((:DwmModifyPreviousDxFrameDuration, "dwmapi.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Int32, Int32),
      hwnd, cRefreshes, fRelative)
# hwnd : HWND -> Ptr{Cvoid}
# cRefreshes : INT -> Int32
# fRelative : BOOL -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t DwmModifyPreviousDxFrameDuration(
    void* hwnd,
    int32_t cRefreshes,
    int32_t fRelative);
]]
local dwmapi = ffi.load("dwmapi")
-- dwmapi.DwmModifyPreviousDxFrameDuration(hwnd, cRefreshes, fRelative)
-- hwnd : HWND
-- cRefreshes : INT
-- fRelative : BOOL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('dwmapi.dll');
const DwmModifyPreviousDxFrameDuration = lib.func('__stdcall', 'DwmModifyPreviousDxFrameDuration', 'int32_t', ['void *', 'int32_t', 'int32_t']);
// DwmModifyPreviousDxFrameDuration(hwnd, cRefreshes, fRelative)
// hwnd : HWND -> 'void *'
// cRefreshes : INT -> 'int32_t'
// fRelative : BOOL -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("dwmapi.dll", {
  DwmModifyPreviousDxFrameDuration: { parameters: ["pointer", "i32", "i32"], result: "i32" },
});
// lib.symbols.DwmModifyPreviousDxFrameDuration(hwnd, cRefreshes, fRelative)
// hwnd : HWND -> "pointer"
// cRefreshes : INT -> "i32"
// fRelative : BOOL -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t DwmModifyPreviousDxFrameDuration(
    void* hwnd,
    int32_t cRefreshes,
    int32_t fRelative);
C, "dwmapi.dll");
// $ffi->DwmModifyPreviousDxFrameDuration(hwnd, cRefreshes, fRelative);
// hwnd : HWND
// cRefreshes : INT
// fRelative : BOOL
// 構造体/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 Dwmapi extends StdCallLibrary {
    Dwmapi INSTANCE = Native.load("dwmapi", Dwmapi.class);
    int DwmModifyPreviousDxFrameDuration(
        Pointer hwnd,   // HWND
        int cRefreshes,   // INT
        boolean fRelative   // BOOL
    );
}
@[Link("dwmapi")]
lib Libdwmapi
  fun DwmModifyPreviousDxFrameDuration = DwmModifyPreviousDxFrameDuration(
    hwnd : Void*,   # HWND
    cRefreshes : Int32,   # INT
    fRelative : Int32   # BOOL
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef DwmModifyPreviousDxFrameDurationNative = Int32 Function(Pointer<Void>, Int32, Int32);
typedef DwmModifyPreviousDxFrameDurationDart = int Function(Pointer<Void>, int, int);
final DwmModifyPreviousDxFrameDuration = DynamicLibrary.open('dwmapi.dll')
    .lookupFunction<DwmModifyPreviousDxFrameDurationNative, DwmModifyPreviousDxFrameDurationDart>('DwmModifyPreviousDxFrameDuration');
// hwnd : HWND -> Pointer<Void>
// cRefreshes : INT -> Int32
// fRelative : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function DwmModifyPreviousDxFrameDuration(
  hwnd: THandle;   // HWND
  cRefreshes: Integer;   // INT
  fRelative: BOOL   // BOOL
): Integer; stdcall;
  external 'dwmapi.dll' name 'DwmModifyPreviousDxFrameDuration';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DwmModifyPreviousDxFrameDuration"
  c_DwmModifyPreviousDxFrameDuration :: Ptr () -> Int32 -> CInt -> IO Int32
-- hwnd : HWND -> Ptr ()
-- cRefreshes : INT -> Int32
-- fRelative : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let dwmmodifypreviousdxframeduration =
  foreign "DwmModifyPreviousDxFrameDuration"
    ((ptr void) @-> int32_t @-> int32_t @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* cRefreshes : INT -> int32_t *)
(* fRelative : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dwmapi (t "dwmapi.dll"))
(cffi:use-foreign-library dwmapi)

(cffi:defcfun ("DwmModifyPreviousDxFrameDuration" dwm-modify-previous-dx-frame-duration :convention :stdcall) :int32
  (hwnd :pointer)   ; HWND
  (c-refreshes :int32)   ; INT
  (f-relative :int32))   ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DwmModifyPreviousDxFrameDuration = Win32::API::More->new('dwmapi',
    'int DwmModifyPreviousDxFrameDuration(HANDLE hwnd, int cRefreshes, BOOL fRelative)');
# my $ret = $DwmModifyPreviousDxFrameDuration->Call($hwnd, $cRefreshes, $fRelative);
# hwnd : HWND -> HANDLE
# cRefreshes : INT -> int
# fRelative : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。