ホーム › UI.WindowsAndMessaging › SetWindowDisplayAffinity
SetWindowDisplayAffinity
関数ウィンドウの画面キャプチャ可否を設定する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL SetWindowDisplayAffinity(
HWND hWnd,
WINDOW_DISPLAY_AFFINITY dwAffinity
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | in |
| dwAffinity | WINDOW_DISPLAY_AFFINITY | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL SetWindowDisplayAffinity(
HWND hWnd,
WINDOW_DISPLAY_AFFINITY dwAffinity
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetWindowDisplayAffinity(
IntPtr hWnd, // HWND
uint dwAffinity // WINDOW_DISPLAY_AFFINITY
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetWindowDisplayAffinity(
hWnd As IntPtr, ' HWND
dwAffinity As UInteger ' WINDOW_DISPLAY_AFFINITY
) As Boolean
End Function' hWnd : HWND
' dwAffinity : WINDOW_DISPLAY_AFFINITY
Declare PtrSafe Function SetWindowDisplayAffinity Lib "user32" ( _
ByVal hWnd As LongPtr, _
ByVal dwAffinity As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetWindowDisplayAffinity = ctypes.windll.user32.SetWindowDisplayAffinity
SetWindowDisplayAffinity.restype = wintypes.BOOL
SetWindowDisplayAffinity.argtypes = [
wintypes.HANDLE, # hWnd : HWND
wintypes.DWORD, # dwAffinity : WINDOW_DISPLAY_AFFINITY
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
SetWindowDisplayAffinity = Fiddle::Function.new(
lib['SetWindowDisplayAffinity'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
-Fiddle::TYPE_INT, # dwAffinity : WINDOW_DISPLAY_AFFINITY
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn SetWindowDisplayAffinity(
hWnd: *mut core::ffi::c_void, // HWND
dwAffinity: u32 // WINDOW_DISPLAY_AFFINITY
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool SetWindowDisplayAffinity(IntPtr hWnd, uint dwAffinity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetWindowDisplayAffinity' -Namespace Win32 -PassThru
# $api::SetWindowDisplayAffinity(hWnd, dwAffinity)#uselib "USER32.dll"
#func global SetWindowDisplayAffinity "SetWindowDisplayAffinity" sptr, sptr
; SetWindowDisplayAffinity hWnd, dwAffinity ; 戻り値は stat
; hWnd : HWND -> "sptr"
; dwAffinity : WINDOW_DISPLAY_AFFINITY -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global SetWindowDisplayAffinity "SetWindowDisplayAffinity" sptr, int
; res = SetWindowDisplayAffinity(hWnd, dwAffinity)
; hWnd : HWND -> "sptr"
; dwAffinity : WINDOW_DISPLAY_AFFINITY -> "int"; BOOL SetWindowDisplayAffinity(HWND hWnd, WINDOW_DISPLAY_AFFINITY dwAffinity)
#uselib "USER32.dll"
#cfunc global SetWindowDisplayAffinity "SetWindowDisplayAffinity" intptr, int
; res = SetWindowDisplayAffinity(hWnd, dwAffinity)
; hWnd : HWND -> "intptr"
; dwAffinity : WINDOW_DISPLAY_AFFINITY -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procSetWindowDisplayAffinity = user32.NewProc("SetWindowDisplayAffinity")
)
// hWnd (HWND), dwAffinity (WINDOW_DISPLAY_AFFINITY)
r1, _, err := procSetWindowDisplayAffinity.Call(
uintptr(hWnd),
uintptr(dwAffinity),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetWindowDisplayAffinity(
hWnd: THandle; // HWND
dwAffinity: DWORD // WINDOW_DISPLAY_AFFINITY
): BOOL; stdcall;
external 'USER32.dll' name 'SetWindowDisplayAffinity';result := DllCall("USER32\SetWindowDisplayAffinity"
, "Ptr", hWnd ; HWND
, "UInt", dwAffinity ; WINDOW_DISPLAY_AFFINITY
, "Int") ; return: BOOL●SetWindowDisplayAffinity(hWnd, dwAffinity) = DLL("USER32.dll", "bool SetWindowDisplayAffinity(void*, dword)")
# 呼び出し: SetWindowDisplayAffinity(hWnd, dwAffinity)
# hWnd : HWND -> "void*"
# dwAffinity : WINDOW_DISPLAY_AFFINITY -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。