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