ホーム › Data.RightsManagement › DRMIsWindowProtected
DRMIsWindowProtected
関数ウィンドウがRMS保護されているか確認する。
シグネチャ
// msdrm.dll
#include <windows.h>
HRESULT DRMIsWindowProtected(
HWND hwnd,
BOOL* pfProtected
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | 保護状態を確認するウィンドウのハンドル。 |
| pfProtected | BOOL* | 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 bool pfProtected // BOOL* in/out
);<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMIsWindowProtected(
hwnd As IntPtr, ' HWND
ByRef pfProtected As Boolean ' 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 bool 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, varptr(pfProtected) ; 戻り値は stat
; hwnd : HWND -> "sptr"
; pfProtected : BOOL* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msdrm.dll" #cfunc global DRMIsWindowProtected "DRMIsWindowProtected" sptr, var ; res = DRMIsWindowProtected(hwnd, pfProtected) ; hwnd : HWND -> "sptr" ; pfProtected : BOOL* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msdrm.dll" #cfunc global DRMIsWindowProtected "DRMIsWindowProtected" sptr, sptr ; res = DRMIsWindowProtected(hwnd, varptr(pfProtected)) ; hwnd : HWND -> "sptr" ; pfProtected : BOOL* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DRMIsWindowProtected(HWND hwnd, BOOL* pfProtected) #uselib "msdrm.dll" #cfunc global DRMIsWindowProtected "DRMIsWindowProtected" intptr, var ; res = DRMIsWindowProtected(hwnd, pfProtected) ; hwnd : HWND -> "intptr" ; pfProtected : BOOL* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DRMIsWindowProtected(HWND hwnd, BOOL* pfProtected) #uselib "msdrm.dll" #cfunc global DRMIsWindowProtected "DRMIsWindowProtected" intptr, intptr ; res = DRMIsWindowProtected(hwnd, varptr(pfProtected)) ; hwnd : HWND -> "intptr" ; pfProtected : BOOL* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
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 // HRESULTfunction 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)。const std = @import("std");
extern "msdrm" fn DRMIsWindowProtected(
hwnd: ?*anyopaque, // HWND
pfProtected: [*c]i32 // BOOL* in/out
) callconv(std.os.windows.WINAPI) i32;proc DRMIsWindowProtected(
hwnd: pointer, # HWND
pfProtected: ptr int32 # BOOL* in/out
): int32 {.importc: "DRMIsWindowProtected", stdcall, dynlib: "msdrm.dll".}pragma(lib, "msdrm");
extern(Windows)
int DRMIsWindowProtected(
void* hwnd, // HWND
int* pfProtected // BOOL* in/out
);ccall((:DRMIsWindowProtected, "msdrm.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Int32}),
hwnd, pfProtected)
# hwnd : HWND -> Ptr{Cvoid}
# pfProtected : BOOL* in/out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DRMIsWindowProtected(
void* hwnd,
int32_t* pfProtected);
]]
local msdrm = ffi.load("msdrm")
-- msdrm.DRMIsWindowProtected(hwnd, pfProtected)
-- hwnd : HWND
-- pfProtected : BOOL* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msdrm.dll');
const DRMIsWindowProtected = lib.func('__stdcall', 'DRMIsWindowProtected', 'int32_t', ['void *', 'int32_t *']);
// DRMIsWindowProtected(hwnd, pfProtected)
// hwnd : HWND -> 'void *'
// pfProtected : BOOL* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msdrm.dll", {
DRMIsWindowProtected: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.DRMIsWindowProtected(hwnd, pfProtected)
// hwnd : HWND -> "pointer"
// pfProtected : BOOL* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DRMIsWindowProtected(
void* hwnd,
int32_t* pfProtected);
C, "msdrm.dll");
// $ffi->DRMIsWindowProtected(hwnd, pfProtected);
// hwnd : HWND
// pfProtected : BOOL* 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 Msdrm extends StdCallLibrary {
Msdrm INSTANCE = Native.load("msdrm", Msdrm.class);
int DRMIsWindowProtected(
Pointer hwnd, // HWND
IntByReference pfProtected // BOOL* in/out
);
}@[Link("msdrm")]
lib Libmsdrm
fun DRMIsWindowProtected = DRMIsWindowProtected(
hwnd : Void*, # HWND
pfProtected : Int32* # BOOL* 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 DRMIsWindowProtectedNative = Int32 Function(Pointer<Void>, Pointer<Int32>);
typedef DRMIsWindowProtectedDart = int Function(Pointer<Void>, Pointer<Int32>);
final DRMIsWindowProtected = DynamicLibrary.open('msdrm.dll')
.lookupFunction<DRMIsWindowProtectedNative, DRMIsWindowProtectedDart>('DRMIsWindowProtected');
// hwnd : HWND -> Pointer<Void>
// pfProtected : BOOL* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DRMIsWindowProtected(
hwnd: THandle; // HWND
pfProtected: Pointer // BOOL* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMIsWindowProtected';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DRMIsWindowProtected"
c_DRMIsWindowProtected :: Ptr () -> Ptr CInt -> IO Int32
-- hwnd : HWND -> Ptr ()
-- pfProtected : BOOL* in/out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drmiswindowprotected =
foreign "DRMIsWindowProtected"
((ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* pfProtected : BOOL* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msdrm (t "msdrm.dll"))
(cffi:use-foreign-library msdrm)
(cffi:defcfun ("DRMIsWindowProtected" drmis-window-protected :convention :stdcall) :int32
(hwnd :pointer) ; HWND
(pf-protected :pointer)) ; BOOL* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DRMIsWindowProtected = Win32::API::More->new('msdrm',
'int DRMIsWindowProtected(HANDLE hwnd, LPVOID pfProtected)');
# my $ret = $DRMIsWindowProtected->Call($hwnd, $pfProtected);
# hwnd : HWND -> HANDLE
# pfProtected : BOOL* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。