ホーム › Graphics.Dwm › DwmSetPresentParameters
DwmSetPresentParameters
関数DWMへのフレーム表示パラメーターを設定する。
シグネチャ
// dwmapi.dll
#include <windows.h>
HRESULT DwmSetPresentParameters(
HWND hwnd,
DWM_PRESENT_PARAMETERS* pPresentParams
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | 提示パラメーターを設定する対象のウィンドウハンドル。 |
| pPresentParams | DWM_PRESENT_PARAMETERS* | inout | 提示動作を指定するDWM_PRESENT_PARAMETERS構造体。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// dwmapi.dll
#include <windows.h>
HRESULT DwmSetPresentParameters(
HWND hwnd,
DWM_PRESENT_PARAMETERS* pPresentParams
);[DllImport("dwmapi.dll", ExactSpelling = true)]
static extern int DwmSetPresentParameters(
IntPtr hwnd, // HWND
IntPtr pPresentParams // DWM_PRESENT_PARAMETERS* in/out
);<DllImport("dwmapi.dll", ExactSpelling:=True)>
Public Shared Function DwmSetPresentParameters(
hwnd As IntPtr, ' HWND
pPresentParams As IntPtr ' DWM_PRESENT_PARAMETERS* in/out
) As Integer
End Function' hwnd : HWND
' pPresentParams : DWM_PRESENT_PARAMETERS* in/out
Declare PtrSafe Function DwmSetPresentParameters Lib "dwmapi" ( _
ByVal hwnd As LongPtr, _
ByVal pPresentParams As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DwmSetPresentParameters = ctypes.windll.dwmapi.DwmSetPresentParameters
DwmSetPresentParameters.restype = ctypes.c_int
DwmSetPresentParameters.argtypes = [
wintypes.HANDLE, # hwnd : HWND
ctypes.c_void_p, # pPresentParams : DWM_PRESENT_PARAMETERS* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dwmapi.dll')
DwmSetPresentParameters = Fiddle::Function.new(
lib['DwmSetPresentParameters'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_VOIDP, # pPresentParams : DWM_PRESENT_PARAMETERS* in/out
],
Fiddle::TYPE_INT)#[link(name = "dwmapi")]
extern "system" {
fn DwmSetPresentParameters(
hwnd: *mut core::ffi::c_void, // HWND
pPresentParams: *mut DWM_PRESENT_PARAMETERS // DWM_PRESENT_PARAMETERS* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("dwmapi.dll")]
public static extern int DwmSetPresentParameters(IntPtr hwnd, IntPtr pPresentParams);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dwmapi_DwmSetPresentParameters' -Namespace Win32 -PassThru
# $api::DwmSetPresentParameters(hwnd, pPresentParams)#uselib "dwmapi.dll"
#func global DwmSetPresentParameters "DwmSetPresentParameters" sptr, sptr
; DwmSetPresentParameters hwnd, varptr(pPresentParams) ; 戻り値は stat
; hwnd : HWND -> "sptr"
; pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "dwmapi.dll" #cfunc global DwmSetPresentParameters "DwmSetPresentParameters" sptr, var ; res = DwmSetPresentParameters(hwnd, pPresentParams) ; hwnd : HWND -> "sptr" ; pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "dwmapi.dll" #cfunc global DwmSetPresentParameters "DwmSetPresentParameters" sptr, sptr ; res = DwmSetPresentParameters(hwnd, varptr(pPresentParams)) ; hwnd : HWND -> "sptr" ; pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DwmSetPresentParameters(HWND hwnd, DWM_PRESENT_PARAMETERS* pPresentParams) #uselib "dwmapi.dll" #cfunc global DwmSetPresentParameters "DwmSetPresentParameters" intptr, var ; res = DwmSetPresentParameters(hwnd, pPresentParams) ; hwnd : HWND -> "intptr" ; pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DwmSetPresentParameters(HWND hwnd, DWM_PRESENT_PARAMETERS* pPresentParams) #uselib "dwmapi.dll" #cfunc global DwmSetPresentParameters "DwmSetPresentParameters" intptr, intptr ; res = DwmSetPresentParameters(hwnd, varptr(pPresentParams)) ; hwnd : HWND -> "intptr" ; pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dwmapi = windows.NewLazySystemDLL("dwmapi.dll")
procDwmSetPresentParameters = dwmapi.NewProc("DwmSetPresentParameters")
)
// hwnd (HWND), pPresentParams (DWM_PRESENT_PARAMETERS* in/out)
r1, _, err := procDwmSetPresentParameters.Call(
uintptr(hwnd),
uintptr(pPresentParams),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DwmSetPresentParameters(
hwnd: THandle; // HWND
pPresentParams: Pointer // DWM_PRESENT_PARAMETERS* in/out
): Integer; stdcall;
external 'dwmapi.dll' name 'DwmSetPresentParameters';result := DllCall("dwmapi\DwmSetPresentParameters"
, "Ptr", hwnd ; HWND
, "Ptr", pPresentParams ; DWM_PRESENT_PARAMETERS* in/out
, "Int") ; return: HRESULT●DwmSetPresentParameters(hwnd, pPresentParams) = DLL("dwmapi.dll", "int DwmSetPresentParameters(void*, void*)")
# 呼び出し: DwmSetPresentParameters(hwnd, pPresentParams)
# hwnd : HWND -> "void*"
# pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dwmapi" fn DwmSetPresentParameters(
hwnd: ?*anyopaque, // HWND
pPresentParams: [*c]DWM_PRESENT_PARAMETERS // DWM_PRESENT_PARAMETERS* in/out
) callconv(std.os.windows.WINAPI) i32;proc DwmSetPresentParameters(
hwnd: pointer, # HWND
pPresentParams: ptr DWM_PRESENT_PARAMETERS # DWM_PRESENT_PARAMETERS* in/out
): int32 {.importc: "DwmSetPresentParameters", stdcall, dynlib: "dwmapi.dll".}pragma(lib, "dwmapi");
extern(Windows)
int DwmSetPresentParameters(
void* hwnd, // HWND
DWM_PRESENT_PARAMETERS* pPresentParams // DWM_PRESENT_PARAMETERS* in/out
);ccall((:DwmSetPresentParameters, "dwmapi.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{DWM_PRESENT_PARAMETERS}),
hwnd, pPresentParams)
# hwnd : HWND -> Ptr{Cvoid}
# pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> Ptr{DWM_PRESENT_PARAMETERS}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DwmSetPresentParameters(
void* hwnd,
void* pPresentParams);
]]
local dwmapi = ffi.load("dwmapi")
-- dwmapi.DwmSetPresentParameters(hwnd, pPresentParams)
-- hwnd : HWND
-- pPresentParams : DWM_PRESENT_PARAMETERS* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('dwmapi.dll');
const DwmSetPresentParameters = lib.func('__stdcall', 'DwmSetPresentParameters', 'int32_t', ['void *', 'void *']);
// DwmSetPresentParameters(hwnd, pPresentParams)
// hwnd : HWND -> 'void *'
// pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("dwmapi.dll", {
DwmSetPresentParameters: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.DwmSetPresentParameters(hwnd, pPresentParams)
// hwnd : HWND -> "pointer"
// pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DwmSetPresentParameters(
void* hwnd,
void* pPresentParams);
C, "dwmapi.dll");
// $ffi->DwmSetPresentParameters(hwnd, pPresentParams);
// hwnd : HWND
// pPresentParams : DWM_PRESENT_PARAMETERS* in/out
// 構造体/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 DwmSetPresentParameters(
Pointer hwnd, // HWND
Pointer pPresentParams // DWM_PRESENT_PARAMETERS* in/out
);
}@[Link("dwmapi")]
lib Libdwmapi
fun DwmSetPresentParameters = DwmSetPresentParameters(
hwnd : Void*, # HWND
pPresentParams : DWM_PRESENT_PARAMETERS* # DWM_PRESENT_PARAMETERS* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DwmSetPresentParametersNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef DwmSetPresentParametersDart = int Function(Pointer<Void>, Pointer<Void>);
final DwmSetPresentParameters = DynamicLibrary.open('dwmapi.dll')
.lookupFunction<DwmSetPresentParametersNative, DwmSetPresentParametersDart>('DwmSetPresentParameters');
// hwnd : HWND -> Pointer<Void>
// pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DwmSetPresentParameters(
hwnd: THandle; // HWND
pPresentParams: Pointer // DWM_PRESENT_PARAMETERS* in/out
): Integer; stdcall;
external 'dwmapi.dll' name 'DwmSetPresentParameters';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DwmSetPresentParameters"
c_DwmSetPresentParameters :: Ptr () -> Ptr () -> IO Int32
-- hwnd : HWND -> Ptr ()
-- pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dwmsetpresentparameters =
foreign "DwmSetPresentParameters"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dwmapi (t "dwmapi.dll"))
(cffi:use-foreign-library dwmapi)
(cffi:defcfun ("DwmSetPresentParameters" dwm-set-present-parameters :convention :stdcall) :int32
(hwnd :pointer) ; HWND
(p-present-params :pointer)) ; DWM_PRESENT_PARAMETERS* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DwmSetPresentParameters = Win32::API::More->new('dwmapi',
'int DwmSetPresentParameters(HANDLE hwnd, LPVOID pPresentParams)');
# my $ret = $DwmSetPresentParameters->Call($hwnd, $pPresentParams);
# hwnd : HWND -> HANDLE
# pPresentParams : DWM_PRESENT_PARAMETERS* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。