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

DRMCreateBoundLicense

関数
RMSのバインド済みライセンスを作成する。
DLLmsdrm.dll呼出規約winapi

シグネチャ

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

HRESULT DRMCreateBoundLicense(
    DWORD hEnv,
    DRMBOUNDLICENSEPARAMS* pParams,
    LPWSTR wszLicenseChain,
    DWORD* phBoundLicense,
    DWORD* phErrorLog
);

パラメーター

名前方向
hEnvDWORDin
pParamsDRMBOUNDLICENSEPARAMS*inout
wszLicenseChainLPWSTRin
phBoundLicenseDWORD*inout
phErrorLogDWORD*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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // HRESULT
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';
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)。