Win32 API 日本語リファレンス
ホームData.RightsManagement › DRMIsWindowProtected

DRMIsWindowProtected

関数
ウィンドウがRMS保護されているか確認する。
DLLmsdrm.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT DRMIsWindowProtected(
    HWND hwnd,
    BOOL* pfProtected
);

パラメーター

名前方向
hwndHWNDin
pfProtectedBOOL*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DRMIsWindowProtected(
    HWND hwnd,
    BOOL* pfProtected
);
[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMIsWindowProtected(
    IntPtr hwnd,   // HWND
    ref int pfProtected   // BOOL* in/out
);
<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMIsWindowProtected(
    hwnd As IntPtr,   ' HWND
    ByRef pfProtected As Integer   ' BOOL* in/out
) As Integer
End Function
' hwnd : HWND
' pfProtected : BOOL* in/out
Declare PtrSafe Function DRMIsWindowProtected Lib "msdrm" ( _
    ByVal hwnd As LongPtr, _
    ByRef pfProtected As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DRMIsWindowProtected = ctypes.windll.msdrm.DRMIsWindowProtected
DRMIsWindowProtected.restype = ctypes.c_int
DRMIsWindowProtected.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    ctypes.c_void_p,  # pfProtected : BOOL* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msdrm = windows.NewLazySystemDLL("msdrm.dll")
	procDRMIsWindowProtected = msdrm.NewProc("DRMIsWindowProtected")
)

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