ホーム › Data.RightsManagement › DRMParseUnboundLicense
DRMParseUnboundLicense
関数未バインドのライセンスを解析しクエリハンドルを得る。
シグネチャ
// msdrm.dll
#include <windows.h>
HRESULT DRMParseUnboundLicense(
LPWSTR wszCertificate,
DWORD* phQueryRoot
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| wszCertificate | LPWSTR | in | 解析対象の未バインドライセンス文字列を示すUnicode文字列。 |
| phQueryRoot | DWORD* | inout | 解析結果のクエリ起点ハンドルを受け取る出力先。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// msdrm.dll
#include <windows.h>
HRESULT DRMParseUnboundLicense(
LPWSTR wszCertificate,
DWORD* phQueryRoot
);[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMParseUnboundLicense(
[MarshalAs(UnmanagedType.LPWStr)] string wszCertificate, // LPWSTR
ref uint phQueryRoot // DWORD* in/out
);<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMParseUnboundLicense(
<MarshalAs(UnmanagedType.LPWStr)> wszCertificate As String, ' LPWSTR
ByRef phQueryRoot As UInteger ' DWORD* in/out
) As Integer
End Function' wszCertificate : LPWSTR
' phQueryRoot : DWORD* in/out
Declare PtrSafe Function DRMParseUnboundLicense Lib "msdrm" ( _
ByVal wszCertificate As LongPtr, _
ByRef phQueryRoot As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DRMParseUnboundLicense = ctypes.windll.msdrm.DRMParseUnboundLicense
DRMParseUnboundLicense.restype = ctypes.c_int
DRMParseUnboundLicense.argtypes = [
wintypes.LPCWSTR, # wszCertificate : LPWSTR
ctypes.POINTER(wintypes.DWORD), # phQueryRoot : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msdrm.dll')
DRMParseUnboundLicense = Fiddle::Function.new(
lib['DRMParseUnboundLicense'],
[
Fiddle::TYPE_VOIDP, # wszCertificate : LPWSTR
Fiddle::TYPE_VOIDP, # phQueryRoot : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "msdrm")]
extern "system" {
fn DRMParseUnboundLicense(
wszCertificate: *mut u16, // LPWSTR
phQueryRoot: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msdrm.dll")]
public static extern int DRMParseUnboundLicense([MarshalAs(UnmanagedType.LPWStr)] string wszCertificate, ref uint phQueryRoot);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msdrm_DRMParseUnboundLicense' -Namespace Win32 -PassThru
# $api::DRMParseUnboundLicense(wszCertificate, phQueryRoot)#uselib "msdrm.dll"
#func global DRMParseUnboundLicense "DRMParseUnboundLicense" sptr, sptr
; DRMParseUnboundLicense wszCertificate, varptr(phQueryRoot) ; 戻り値は stat
; wszCertificate : LPWSTR -> "sptr"
; phQueryRoot : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msdrm.dll" #cfunc global DRMParseUnboundLicense "DRMParseUnboundLicense" wstr, var ; res = DRMParseUnboundLicense(wszCertificate, phQueryRoot) ; wszCertificate : LPWSTR -> "wstr" ; phQueryRoot : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msdrm.dll" #cfunc global DRMParseUnboundLicense "DRMParseUnboundLicense" wstr, sptr ; res = DRMParseUnboundLicense(wszCertificate, varptr(phQueryRoot)) ; wszCertificate : LPWSTR -> "wstr" ; phQueryRoot : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DRMParseUnboundLicense(LPWSTR wszCertificate, DWORD* phQueryRoot) #uselib "msdrm.dll" #cfunc global DRMParseUnboundLicense "DRMParseUnboundLicense" wstr, var ; res = DRMParseUnboundLicense(wszCertificate, phQueryRoot) ; wszCertificate : LPWSTR -> "wstr" ; phQueryRoot : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DRMParseUnboundLicense(LPWSTR wszCertificate, DWORD* phQueryRoot) #uselib "msdrm.dll" #cfunc global DRMParseUnboundLicense "DRMParseUnboundLicense" wstr, intptr ; res = DRMParseUnboundLicense(wszCertificate, varptr(phQueryRoot)) ; wszCertificate : LPWSTR -> "wstr" ; phQueryRoot : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msdrm = windows.NewLazySystemDLL("msdrm.dll")
procDRMParseUnboundLicense = msdrm.NewProc("DRMParseUnboundLicense")
)
// wszCertificate (LPWSTR), phQueryRoot (DWORD* in/out)
r1, _, err := procDRMParseUnboundLicense.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszCertificate))),
uintptr(phQueryRoot),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DRMParseUnboundLicense(
wszCertificate: PWideChar; // LPWSTR
phQueryRoot: Pointer // DWORD* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMParseUnboundLicense';result := DllCall("msdrm\DRMParseUnboundLicense"
, "WStr", wszCertificate ; LPWSTR
, "Ptr", phQueryRoot ; DWORD* in/out
, "Int") ; return: HRESULT●DRMParseUnboundLicense(wszCertificate, phQueryRoot) = DLL("msdrm.dll", "int DRMParseUnboundLicense(char*, void*)")
# 呼び出し: DRMParseUnboundLicense(wszCertificate, phQueryRoot)
# wszCertificate : LPWSTR -> "char*"
# phQueryRoot : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msdrm" fn DRMParseUnboundLicense(
wszCertificate: [*c]const u16, // LPWSTR
phQueryRoot: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;proc DRMParseUnboundLicense(
wszCertificate: WideCString, # LPWSTR
phQueryRoot: ptr uint32 # DWORD* in/out
): int32 {.importc: "DRMParseUnboundLicense", stdcall, dynlib: "msdrm.dll".}pragma(lib, "msdrm");
extern(Windows)
int DRMParseUnboundLicense(
const(wchar)* wszCertificate, // LPWSTR
uint* phQueryRoot // DWORD* in/out
);ccall((:DRMParseUnboundLicense, "msdrm.dll"), stdcall, Int32,
(Cwstring, Ptr{UInt32}),
wszCertificate, phQueryRoot)
# wszCertificate : LPWSTR -> Cwstring
# phQueryRoot : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DRMParseUnboundLicense(
const uint16_t* wszCertificate,
uint32_t* phQueryRoot);
]]
local msdrm = ffi.load("msdrm")
-- msdrm.DRMParseUnboundLicense(wszCertificate, phQueryRoot)
-- wszCertificate : LPWSTR
-- phQueryRoot : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msdrm.dll');
const DRMParseUnboundLicense = lib.func('__stdcall', 'DRMParseUnboundLicense', 'int32_t', ['str16', 'uint32_t *']);
// DRMParseUnboundLicense(wszCertificate, phQueryRoot)
// wszCertificate : LPWSTR -> 'str16'
// phQueryRoot : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msdrm.dll", {
DRMParseUnboundLicense: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.DRMParseUnboundLicense(wszCertificate, phQueryRoot)
// wszCertificate : LPWSTR -> "buffer"
// phQueryRoot : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DRMParseUnboundLicense(
const uint16_t* wszCertificate,
uint32_t* phQueryRoot);
C, "msdrm.dll");
// $ffi->DRMParseUnboundLicense(wszCertificate, phQueryRoot);
// wszCertificate : LPWSTR
// phQueryRoot : DWORD* 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 DRMParseUnboundLicense(
WString wszCertificate, // LPWSTR
IntByReference phQueryRoot // DWORD* in/out
);
}@[Link("msdrm")]
lib Libmsdrm
fun DRMParseUnboundLicense = DRMParseUnboundLicense(
wszCertificate : UInt16*, # LPWSTR
phQueryRoot : UInt32* # DWORD* 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 DRMParseUnboundLicenseNative = Int32 Function(Pointer<Utf16>, Pointer<Uint32>);
typedef DRMParseUnboundLicenseDart = int Function(Pointer<Utf16>, Pointer<Uint32>);
final DRMParseUnboundLicense = DynamicLibrary.open('msdrm.dll')
.lookupFunction<DRMParseUnboundLicenseNative, DRMParseUnboundLicenseDart>('DRMParseUnboundLicense');
// wszCertificate : LPWSTR -> Pointer<Utf16>
// phQueryRoot : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DRMParseUnboundLicense(
wszCertificate: PWideChar; // LPWSTR
phQueryRoot: Pointer // DWORD* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMParseUnboundLicense';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DRMParseUnboundLicense"
c_DRMParseUnboundLicense :: CWString -> Ptr Word32 -> IO Int32
-- wszCertificate : LPWSTR -> CWString
-- phQueryRoot : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drmparseunboundlicense =
foreign "DRMParseUnboundLicense"
((ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* wszCertificate : LPWSTR -> (ptr uint16_t) *)
(* phQueryRoot : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msdrm (t "msdrm.dll"))
(cffi:use-foreign-library msdrm)
(cffi:defcfun ("DRMParseUnboundLicense" drmparse-unbound-license :convention :stdcall) :int32
(wsz-certificate (:string :encoding :utf-16le)) ; LPWSTR
(ph-query-root :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DRMParseUnboundLicense = Win32::API::More->new('msdrm',
'int DRMParseUnboundLicense(LPCWSTR wszCertificate, LPVOID phQueryRoot)');
# my $ret = $DRMParseUnboundLicense->Call($wszCertificate, $phQueryRoot);
# wszCertificate : LPWSTR -> LPCWSTR
# phQueryRoot : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。