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