Win32 API 日本語リファレンス
ホームMedia.WindowsMediaFormat › WMIsContentProtected

WMIsContentProtected

関数
指定ファイルがDRM保護されているかを判定する。
DLLWMVCore.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT WMIsContentProtected(
    LPCWSTR pwszFileName,
    BOOL* pfIsProtected
);

パラメーター

名前方向説明
pwszFileNameLPCWSTRin保護状態を調べるメディアファイルのパス文字列(Unicode)。
pfIsProtectedBOOL*inoutDRM保護されているかを受け取るBOOLへのポインタ。出力用。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WMIsContentProtected(
    LPCWSTR pwszFileName,
    BOOL* pfIsProtected
);
[DllImport("WMVCore.dll", ExactSpelling = true)]
static extern int WMIsContentProtected(
    [MarshalAs(UnmanagedType.LPWStr)] string pwszFileName,   // LPCWSTR
    ref bool pfIsProtected   // BOOL* in/out
);
<DllImport("WMVCore.dll", ExactSpelling:=True)>
Public Shared Function WMIsContentProtected(
    <MarshalAs(UnmanagedType.LPWStr)> pwszFileName As String,   ' LPCWSTR
    ByRef pfIsProtected As Boolean   ' BOOL* in/out
) As Integer
End Function
' pwszFileName : LPCWSTR
' pfIsProtected : BOOL* in/out
Declare PtrSafe Function WMIsContentProtected Lib "wmvcore" ( _
    ByVal pwszFileName As LongPtr, _
    ByRef pfIsProtected As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WMIsContentProtected = ctypes.windll.wmvcore.WMIsContentProtected
WMIsContentProtected.restype = ctypes.c_int
WMIsContentProtected.argtypes = [
    wintypes.LPCWSTR,  # pwszFileName : LPCWSTR
    ctypes.c_void_p,  # pfIsProtected : BOOL* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WMVCore.dll')
WMIsContentProtected = Fiddle::Function.new(
  lib['WMIsContentProtected'],
  [
    Fiddle::TYPE_VOIDP,  # pwszFileName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pfIsProtected : BOOL* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "wmvcore")]
extern "system" {
    fn WMIsContentProtected(
        pwszFileName: *const u16,  // LPCWSTR
        pfIsProtected: *mut i32  // BOOL* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WMVCore.dll")]
public static extern int WMIsContentProtected([MarshalAs(UnmanagedType.LPWStr)] string pwszFileName, ref bool pfIsProtected);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WMVCore_WMIsContentProtected' -Namespace Win32 -PassThru
# $api::WMIsContentProtected(pwszFileName, pfIsProtected)
#uselib "WMVCore.dll"
#func global WMIsContentProtected "WMIsContentProtected" sptr, sptr
; WMIsContentProtected pwszFileName, varptr(pfIsProtected)   ; 戻り値は stat
; pwszFileName : LPCWSTR -> "sptr"
; pfIsProtected : BOOL* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WMVCore.dll"
#cfunc global WMIsContentProtected "WMIsContentProtected" wstr, var
; res = WMIsContentProtected(pwszFileName, pfIsProtected)
; pwszFileName : LPCWSTR -> "wstr"
; pfIsProtected : BOOL* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WMIsContentProtected(LPCWSTR pwszFileName, BOOL* pfIsProtected)
#uselib "WMVCore.dll"
#cfunc global WMIsContentProtected "WMIsContentProtected" wstr, var
; res = WMIsContentProtected(pwszFileName, pfIsProtected)
; pwszFileName : LPCWSTR -> "wstr"
; pfIsProtected : BOOL* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wmvcore = windows.NewLazySystemDLL("WMVCore.dll")
	procWMIsContentProtected = wmvcore.NewProc("WMIsContentProtected")
)

// pwszFileName (LPCWSTR), pfIsProtected (BOOL* in/out)
r1, _, err := procWMIsContentProtected.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszFileName))),
	uintptr(pfIsProtected),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WMIsContentProtected(
  pwszFileName: PWideChar;   // LPCWSTR
  pfIsProtected: Pointer   // BOOL* in/out
): Integer; stdcall;
  external 'WMVCore.dll' name 'WMIsContentProtected';
result := DllCall("WMVCore\WMIsContentProtected"
    , "WStr", pwszFileName   ; LPCWSTR
    , "Ptr", pfIsProtected   ; BOOL* in/out
    , "Int")   ; return: HRESULT
●WMIsContentProtected(pwszFileName, pfIsProtected) = DLL("WMVCore.dll", "int WMIsContentProtected(char*, void*)")
# 呼び出し: WMIsContentProtected(pwszFileName, pfIsProtected)
# pwszFileName : LPCWSTR -> "char*"
# pfIsProtected : BOOL* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wmvcore" fn WMIsContentProtected(
    pwszFileName: [*c]const u16, // LPCWSTR
    pfIsProtected: [*c]i32 // BOOL* in/out
) callconv(std.os.windows.WINAPI) i32;
proc WMIsContentProtected(
    pwszFileName: WideCString,  # LPCWSTR
    pfIsProtected: ptr int32  # BOOL* in/out
): int32 {.importc: "WMIsContentProtected", stdcall, dynlib: "WMVCore.dll".}
pragma(lib, "wmvcore");
extern(Windows)
int WMIsContentProtected(
    const(wchar)* pwszFileName,   // LPCWSTR
    int* pfIsProtected   // BOOL* in/out
);
ccall((:WMIsContentProtected, "WMVCore.dll"), stdcall, Int32,
      (Cwstring, Ptr{Int32}),
      pwszFileName, pfIsProtected)
# pwszFileName : LPCWSTR -> Cwstring
# pfIsProtected : BOOL* in/out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WMIsContentProtected(
    const uint16_t* pwszFileName,
    int32_t* pfIsProtected);
]]
local wmvcore = ffi.load("wmvcore")
-- wmvcore.WMIsContentProtected(pwszFileName, pfIsProtected)
-- pwszFileName : LPCWSTR
-- pfIsProtected : BOOL* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WMVCore.dll');
const WMIsContentProtected = lib.func('__stdcall', 'WMIsContentProtected', 'int32_t', ['str16', 'int32_t *']);
// WMIsContentProtected(pwszFileName, pfIsProtected)
// pwszFileName : LPCWSTR -> 'str16'
// pfIsProtected : BOOL* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WMVCore.dll", {
  WMIsContentProtected: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.WMIsContentProtected(pwszFileName, pfIsProtected)
// pwszFileName : LPCWSTR -> "buffer"
// pfIsProtected : BOOL* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WMIsContentProtected(
    const uint16_t* pwszFileName,
    int32_t* pfIsProtected);
C, "WMVCore.dll");
// $ffi->WMIsContentProtected(pwszFileName, pfIsProtected);
// pwszFileName : LPCWSTR
// pfIsProtected : 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 Wmvcore extends StdCallLibrary {
    Wmvcore INSTANCE = Native.load("wmvcore", Wmvcore.class);
    int WMIsContentProtected(
        WString pwszFileName,   // LPCWSTR
        IntByReference pfIsProtected   // BOOL* in/out
    );
}
@[Link("wmvcore")]
lib LibWMVCore
  fun WMIsContentProtected = WMIsContentProtected(
    pwszFileName : UInt16*,   # LPCWSTR
    pfIsProtected : 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 WMIsContentProtectedNative = Int32 Function(Pointer<Utf16>, Pointer<Int32>);
typedef WMIsContentProtectedDart = int Function(Pointer<Utf16>, Pointer<Int32>);
final WMIsContentProtected = DynamicLibrary.open('WMVCore.dll')
    .lookupFunction<WMIsContentProtectedNative, WMIsContentProtectedDart>('WMIsContentProtected');
// pwszFileName : LPCWSTR -> Pointer<Utf16>
// pfIsProtected : BOOL* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WMIsContentProtected(
  pwszFileName: PWideChar;   // LPCWSTR
  pfIsProtected: Pointer   // BOOL* in/out
): Integer; stdcall;
  external 'WMVCore.dll' name 'WMIsContentProtected';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WMIsContentProtected"
  c_WMIsContentProtected :: CWString -> Ptr CInt -> IO Int32
-- pwszFileName : LPCWSTR -> CWString
-- pfIsProtected : BOOL* in/out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wmiscontentprotected =
  foreign "WMIsContentProtected"
    ((ptr uint16_t) @-> (ptr int32_t) @-> returning int32_t)
(* pwszFileName : LPCWSTR -> (ptr uint16_t) *)
(* pfIsProtected : BOOL* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wmvcore (t "WMVCore.dll"))
(cffi:use-foreign-library wmvcore)

(cffi:defcfun ("WMIsContentProtected" wmis-content-protected :convention :stdcall) :int32
  (pwsz-file-name (:string :encoding :utf-16le))   ; LPCWSTR
  (pf-is-protected :pointer))   ; BOOL* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WMIsContentProtected = Win32::API::More->new('WMVCore',
    'int WMIsContentProtected(LPCWSTR pwszFileName, LPVOID pfIsProtected)');
# my $ret = $WMIsContentProtected->Call($pwszFileName, $pfIsProtected);
# pwszFileName : LPCWSTR -> LPCWSTR
# pfIsProtected : BOOL* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。