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