ホーム › Data.RightsManagement › DRMAcquireLicense
DRMAcquireLicense
関数サーバーから使用ライセンスを取得する。
シグネチャ
// msdrm.dll
#include <windows.h>
HRESULT DRMAcquireLicense(
DWORD hSession,
DWORD uFlags,
LPWSTR wszGroupIdentityCredential, // optional
LPWSTR wszRequestedRights, // optional
LPWSTR wszCustomData, // optional
LPWSTR wszURL, // optional
void* pvContext
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hSession | DWORD | in | 対象のセッションハンドル。 |
| uFlags | DWORD | in | ライセンス取得動作を制御するフラグ。 |
| wszGroupIdentityCredential | LPWSTR | inoptional | グループID資格情報を示すUnicode文字列。 |
| wszRequestedRights | LPWSTR | inoptional | 要求する権利を示すUnicode文字列。NULL可。 |
| wszCustomData | LPWSTR | inoptional | サーバーへ送るカスタムデータを示すUnicode文字列。NULL可。 |
| wszURL | LPWSTR | inoptional | ライセンス取得先URLを示すUnicode文字列。NULL可で既定を使用。 |
| pvContext | void* | inout | 非同期コールバックに渡されるユーザー定義コンテキスト。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// msdrm.dll
#include <windows.h>
HRESULT DRMAcquireLicense(
DWORD hSession,
DWORD uFlags,
LPWSTR wszGroupIdentityCredential, // optional
LPWSTR wszRequestedRights, // optional
LPWSTR wszCustomData, // optional
LPWSTR wszURL, // optional
void* pvContext
);[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMAcquireLicense(
uint hSession, // DWORD
uint uFlags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string wszGroupIdentityCredential, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string wszRequestedRights, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string wszCustomData, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string wszURL, // LPWSTR optional
IntPtr pvContext // void* in/out
);<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMAcquireLicense(
hSession As UInteger, ' DWORD
uFlags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> wszGroupIdentityCredential As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> wszRequestedRights As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> wszCustomData As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> wszURL As String, ' LPWSTR optional
pvContext As IntPtr ' void* in/out
) As Integer
End Function' hSession : DWORD
' uFlags : DWORD
' wszGroupIdentityCredential : LPWSTR optional
' wszRequestedRights : LPWSTR optional
' wszCustomData : LPWSTR optional
' wszURL : LPWSTR optional
' pvContext : void* in/out
Declare PtrSafe Function DRMAcquireLicense Lib "msdrm" ( _
ByVal hSession As Long, _
ByVal uFlags As Long, _
ByVal wszGroupIdentityCredential As LongPtr, _
ByVal wszRequestedRights As LongPtr, _
ByVal wszCustomData As LongPtr, _
ByVal wszURL As LongPtr, _
ByVal pvContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DRMAcquireLicense = ctypes.windll.msdrm.DRMAcquireLicense
DRMAcquireLicense.restype = ctypes.c_int
DRMAcquireLicense.argtypes = [
wintypes.DWORD, # hSession : DWORD
wintypes.DWORD, # uFlags : DWORD
wintypes.LPCWSTR, # wszGroupIdentityCredential : LPWSTR optional
wintypes.LPCWSTR, # wszRequestedRights : LPWSTR optional
wintypes.LPCWSTR, # wszCustomData : LPWSTR optional
wintypes.LPCWSTR, # wszURL : LPWSTR optional
ctypes.POINTER(None), # pvContext : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msdrm.dll')
DRMAcquireLicense = Fiddle::Function.new(
lib['DRMAcquireLicense'],
[
-Fiddle::TYPE_INT, # hSession : DWORD
-Fiddle::TYPE_INT, # uFlags : DWORD
Fiddle::TYPE_VOIDP, # wszGroupIdentityCredential : LPWSTR optional
Fiddle::TYPE_VOIDP, # wszRequestedRights : LPWSTR optional
Fiddle::TYPE_VOIDP, # wszCustomData : LPWSTR optional
Fiddle::TYPE_VOIDP, # wszURL : LPWSTR optional
Fiddle::TYPE_VOIDP, # pvContext : void* in/out
],
Fiddle::TYPE_INT)#[link(name = "msdrm")]
extern "system" {
fn DRMAcquireLicense(
hSession: u32, // DWORD
uFlags: u32, // DWORD
wszGroupIdentityCredential: *mut u16, // LPWSTR optional
wszRequestedRights: *mut u16, // LPWSTR optional
wszCustomData: *mut u16, // LPWSTR optional
wszURL: *mut u16, // LPWSTR optional
pvContext: *mut () // void* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msdrm.dll")]
public static extern int DRMAcquireLicense(uint hSession, uint uFlags, [MarshalAs(UnmanagedType.LPWStr)] string wszGroupIdentityCredential, [MarshalAs(UnmanagedType.LPWStr)] string wszRequestedRights, [MarshalAs(UnmanagedType.LPWStr)] string wszCustomData, [MarshalAs(UnmanagedType.LPWStr)] string wszURL, IntPtr pvContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msdrm_DRMAcquireLicense' -Namespace Win32 -PassThru
# $api::DRMAcquireLicense(hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext)#uselib "msdrm.dll"
#func global DRMAcquireLicense "DRMAcquireLicense" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DRMAcquireLicense hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext ; 戻り値は stat
; hSession : DWORD -> "sptr"
; uFlags : DWORD -> "sptr"
; wszGroupIdentityCredential : LPWSTR optional -> "sptr"
; wszRequestedRights : LPWSTR optional -> "sptr"
; wszCustomData : LPWSTR optional -> "sptr"
; wszURL : LPWSTR optional -> "sptr"
; pvContext : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msdrm.dll"
#cfunc global DRMAcquireLicense "DRMAcquireLicense" int, int, wstr, wstr, wstr, wstr, sptr
; res = DRMAcquireLicense(hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext)
; hSession : DWORD -> "int"
; uFlags : DWORD -> "int"
; wszGroupIdentityCredential : LPWSTR optional -> "wstr"
; wszRequestedRights : LPWSTR optional -> "wstr"
; wszCustomData : LPWSTR optional -> "wstr"
; wszURL : LPWSTR optional -> "wstr"
; pvContext : void* in/out -> "sptr"; HRESULT DRMAcquireLicense(DWORD hSession, DWORD uFlags, LPWSTR wszGroupIdentityCredential, LPWSTR wszRequestedRights, LPWSTR wszCustomData, LPWSTR wszURL, void* pvContext)
#uselib "msdrm.dll"
#cfunc global DRMAcquireLicense "DRMAcquireLicense" int, int, wstr, wstr, wstr, wstr, intptr
; res = DRMAcquireLicense(hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext)
; hSession : DWORD -> "int"
; uFlags : DWORD -> "int"
; wszGroupIdentityCredential : LPWSTR optional -> "wstr"
; wszRequestedRights : LPWSTR optional -> "wstr"
; wszCustomData : LPWSTR optional -> "wstr"
; wszURL : LPWSTR optional -> "wstr"
; pvContext : void* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msdrm = windows.NewLazySystemDLL("msdrm.dll")
procDRMAcquireLicense = msdrm.NewProc("DRMAcquireLicense")
)
// hSession (DWORD), uFlags (DWORD), wszGroupIdentityCredential (LPWSTR optional), wszRequestedRights (LPWSTR optional), wszCustomData (LPWSTR optional), wszURL (LPWSTR optional), pvContext (void* in/out)
r1, _, err := procDRMAcquireLicense.Call(
uintptr(hSession),
uintptr(uFlags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszGroupIdentityCredential))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszRequestedRights))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszCustomData))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszURL))),
uintptr(pvContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DRMAcquireLicense(
hSession: DWORD; // DWORD
uFlags: DWORD; // DWORD
wszGroupIdentityCredential: PWideChar; // LPWSTR optional
wszRequestedRights: PWideChar; // LPWSTR optional
wszCustomData: PWideChar; // LPWSTR optional
wszURL: PWideChar; // LPWSTR optional
pvContext: Pointer // void* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMAcquireLicense';result := DllCall("msdrm\DRMAcquireLicense"
, "UInt", hSession ; DWORD
, "UInt", uFlags ; DWORD
, "WStr", wszGroupIdentityCredential ; LPWSTR optional
, "WStr", wszRequestedRights ; LPWSTR optional
, "WStr", wszCustomData ; LPWSTR optional
, "WStr", wszURL ; LPWSTR optional
, "Ptr", pvContext ; void* in/out
, "Int") ; return: HRESULT●DRMAcquireLicense(hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext) = DLL("msdrm.dll", "int DRMAcquireLicense(dword, dword, char*, char*, char*, char*, void*)")
# 呼び出し: DRMAcquireLicense(hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext)
# hSession : DWORD -> "dword"
# uFlags : DWORD -> "dword"
# wszGroupIdentityCredential : LPWSTR optional -> "char*"
# wszRequestedRights : LPWSTR optional -> "char*"
# wszCustomData : LPWSTR optional -> "char*"
# wszURL : LPWSTR optional -> "char*"
# pvContext : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msdrm" fn DRMAcquireLicense(
hSession: u32, // DWORD
uFlags: u32, // DWORD
wszGroupIdentityCredential: [*c]const u16, // LPWSTR optional
wszRequestedRights: [*c]const u16, // LPWSTR optional
wszCustomData: [*c]const u16, // LPWSTR optional
wszURL: [*c]const u16, // LPWSTR optional
pvContext: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;proc DRMAcquireLicense(
hSession: uint32, # DWORD
uFlags: uint32, # DWORD
wszGroupIdentityCredential: WideCString, # LPWSTR optional
wszRequestedRights: WideCString, # LPWSTR optional
wszCustomData: WideCString, # LPWSTR optional
wszURL: WideCString, # LPWSTR optional
pvContext: pointer # void* in/out
): int32 {.importc: "DRMAcquireLicense", stdcall, dynlib: "msdrm.dll".}pragma(lib, "msdrm");
extern(Windows)
int DRMAcquireLicense(
uint hSession, // DWORD
uint uFlags, // DWORD
const(wchar)* wszGroupIdentityCredential, // LPWSTR optional
const(wchar)* wszRequestedRights, // LPWSTR optional
const(wchar)* wszCustomData, // LPWSTR optional
const(wchar)* wszURL, // LPWSTR optional
void* pvContext // void* in/out
);ccall((:DRMAcquireLicense, "msdrm.dll"), stdcall, Int32,
(UInt32, UInt32, Cwstring, Cwstring, Cwstring, Cwstring, Ptr{Cvoid}),
hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext)
# hSession : DWORD -> UInt32
# uFlags : DWORD -> UInt32
# wszGroupIdentityCredential : LPWSTR optional -> Cwstring
# wszRequestedRights : LPWSTR optional -> Cwstring
# wszCustomData : LPWSTR optional -> Cwstring
# wszURL : LPWSTR optional -> Cwstring
# pvContext : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DRMAcquireLicense(
uint32_t hSession,
uint32_t uFlags,
const uint16_t* wszGroupIdentityCredential,
const uint16_t* wszRequestedRights,
const uint16_t* wszCustomData,
const uint16_t* wszURL,
void* pvContext);
]]
local msdrm = ffi.load("msdrm")
-- msdrm.DRMAcquireLicense(hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext)
-- hSession : DWORD
-- uFlags : DWORD
-- wszGroupIdentityCredential : LPWSTR optional
-- wszRequestedRights : LPWSTR optional
-- wszCustomData : LPWSTR optional
-- wszURL : LPWSTR optional
-- pvContext : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msdrm.dll');
const DRMAcquireLicense = lib.func('__stdcall', 'DRMAcquireLicense', 'int32_t', ['uint32_t', 'uint32_t', 'str16', 'str16', 'str16', 'str16', 'void *']);
// DRMAcquireLicense(hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext)
// hSession : DWORD -> 'uint32_t'
// uFlags : DWORD -> 'uint32_t'
// wszGroupIdentityCredential : LPWSTR optional -> 'str16'
// wszRequestedRights : LPWSTR optional -> 'str16'
// wszCustomData : LPWSTR optional -> 'str16'
// wszURL : LPWSTR optional -> 'str16'
// pvContext : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msdrm.dll", {
DRMAcquireLicense: { parameters: ["u32", "u32", "buffer", "buffer", "buffer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.DRMAcquireLicense(hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext)
// hSession : DWORD -> "u32"
// uFlags : DWORD -> "u32"
// wszGroupIdentityCredential : LPWSTR optional -> "buffer"
// wszRequestedRights : LPWSTR optional -> "buffer"
// wszCustomData : LPWSTR optional -> "buffer"
// wszURL : LPWSTR optional -> "buffer"
// pvContext : void* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DRMAcquireLicense(
uint32_t hSession,
uint32_t uFlags,
const uint16_t* wszGroupIdentityCredential,
const uint16_t* wszRequestedRights,
const uint16_t* wszCustomData,
const uint16_t* wszURL,
void* pvContext);
C, "msdrm.dll");
// $ffi->DRMAcquireLicense(hSession, uFlags, wszGroupIdentityCredential, wszRequestedRights, wszCustomData, wszURL, pvContext);
// hSession : DWORD
// uFlags : DWORD
// wszGroupIdentityCredential : LPWSTR optional
// wszRequestedRights : LPWSTR optional
// wszCustomData : LPWSTR optional
// wszURL : LPWSTR optional
// pvContext : void* 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 DRMAcquireLicense(
int hSession, // DWORD
int uFlags, // DWORD
WString wszGroupIdentityCredential, // LPWSTR optional
WString wszRequestedRights, // LPWSTR optional
WString wszCustomData, // LPWSTR optional
WString wszURL, // LPWSTR optional
Pointer pvContext // void* in/out
);
}@[Link("msdrm")]
lib Libmsdrm
fun DRMAcquireLicense = DRMAcquireLicense(
hSession : UInt32, # DWORD
uFlags : UInt32, # DWORD
wszGroupIdentityCredential : UInt16*, # LPWSTR optional
wszRequestedRights : UInt16*, # LPWSTR optional
wszCustomData : UInt16*, # LPWSTR optional
wszURL : UInt16*, # LPWSTR optional
pvContext : Void* # void* 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 DRMAcquireLicenseNative = Int32 Function(Uint32, Uint32, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
typedef DRMAcquireLicenseDart = int Function(int, int, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
final DRMAcquireLicense = DynamicLibrary.open('msdrm.dll')
.lookupFunction<DRMAcquireLicenseNative, DRMAcquireLicenseDart>('DRMAcquireLicense');
// hSession : DWORD -> Uint32
// uFlags : DWORD -> Uint32
// wszGroupIdentityCredential : LPWSTR optional -> Pointer<Utf16>
// wszRequestedRights : LPWSTR optional -> Pointer<Utf16>
// wszCustomData : LPWSTR optional -> Pointer<Utf16>
// wszURL : LPWSTR optional -> Pointer<Utf16>
// pvContext : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DRMAcquireLicense(
hSession: DWORD; // DWORD
uFlags: DWORD; // DWORD
wszGroupIdentityCredential: PWideChar; // LPWSTR optional
wszRequestedRights: PWideChar; // LPWSTR optional
wszCustomData: PWideChar; // LPWSTR optional
wszURL: PWideChar; // LPWSTR optional
pvContext: Pointer // void* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMAcquireLicense';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DRMAcquireLicense"
c_DRMAcquireLicense :: Word32 -> Word32 -> CWString -> CWString -> CWString -> CWString -> Ptr () -> IO Int32
-- hSession : DWORD -> Word32
-- uFlags : DWORD -> Word32
-- wszGroupIdentityCredential : LPWSTR optional -> CWString
-- wszRequestedRights : LPWSTR optional -> CWString
-- wszCustomData : LPWSTR optional -> CWString
-- wszURL : LPWSTR optional -> CWString
-- pvContext : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drmacquirelicense =
foreign "DRMAcquireLicense"
(uint32_t @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* hSession : DWORD -> uint32_t *)
(* uFlags : DWORD -> uint32_t *)
(* wszGroupIdentityCredential : LPWSTR optional -> (ptr uint16_t) *)
(* wszRequestedRights : LPWSTR optional -> (ptr uint16_t) *)
(* wszCustomData : LPWSTR optional -> (ptr uint16_t) *)
(* wszURL : LPWSTR optional -> (ptr uint16_t) *)
(* pvContext : void* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msdrm (t "msdrm.dll"))
(cffi:use-foreign-library msdrm)
(cffi:defcfun ("DRMAcquireLicense" drmacquire-license :convention :stdcall) :int32
(h-session :uint32) ; DWORD
(u-flags :uint32) ; DWORD
(wsz-group-identity-credential (:string :encoding :utf-16le)) ; LPWSTR optional
(wsz-requested-rights (:string :encoding :utf-16le)) ; LPWSTR optional
(wsz-custom-data (:string :encoding :utf-16le)) ; LPWSTR optional
(wsz-url (:string :encoding :utf-16le)) ; LPWSTR optional
(pv-context :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DRMAcquireLicense = Win32::API::More->new('msdrm',
'int DRMAcquireLicense(DWORD hSession, DWORD uFlags, LPCWSTR wszGroupIdentityCredential, LPCWSTR wszRequestedRights, LPCWSTR wszCustomData, LPCWSTR wszURL, LPVOID pvContext)');
# my $ret = $DRMAcquireLicense->Call($hSession, $uFlags, $wszGroupIdentityCredential, $wszRequestedRights, $wszCustomData, $wszURL, $pvContext);
# hSession : DWORD -> DWORD
# uFlags : DWORD -> DWORD
# wszGroupIdentityCredential : LPWSTR optional -> LPCWSTR
# wszRequestedRights : LPWSTR optional -> LPCWSTR
# wszCustomData : LPWSTR optional -> LPCWSTR
# wszURL : LPWSTR optional -> LPCWSTR
# pvContext : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。