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

DRMGetUnboundLicenseObject

関数
未バインドライセンスから指定サブオブジェクトを取得する。
DLLmsdrm.dll呼出規約winapi

シグネチャ

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

HRESULT DRMGetUnboundLicenseObject(
    DWORD hQueryRoot,
    LPWSTR wszSubObjectType,
    DWORD iIndex,
    DWORD* phSubQuery
);

パラメーター

名前方向説明
hQueryRootDWORDinクエリ起点となる未バインドライセンスのハンドル。
wszSubObjectTypeLPWSTRin取得するサブオブジェクトの種別を示すUnicode文字列。
iIndexDWORDin取得する0始まりのインデックス。
phSubQueryDWORD*inout取得したサブオブジェクトのクエリハンドルを受け取る出力先。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DRMGetUnboundLicenseObject(
    DWORD hQueryRoot,
    LPWSTR wszSubObjectType,
    DWORD iIndex,
    DWORD* phSubQuery
);
[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMGetUnboundLicenseObject(
    uint hQueryRoot,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string wszSubObjectType,   // LPWSTR
    uint iIndex,   // DWORD
    ref uint phSubQuery   // DWORD* in/out
);
<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMGetUnboundLicenseObject(
    hQueryRoot As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> wszSubObjectType As String,   ' LPWSTR
    iIndex As UInteger,   ' DWORD
    ByRef phSubQuery As UInteger   ' DWORD* in/out
) As Integer
End Function
' hQueryRoot : DWORD
' wszSubObjectType : LPWSTR
' iIndex : DWORD
' phSubQuery : DWORD* in/out
Declare PtrSafe Function DRMGetUnboundLicenseObject Lib "msdrm" ( _
    ByVal hQueryRoot As Long, _
    ByVal wszSubObjectType As LongPtr, _
    ByVal iIndex As Long, _
    ByRef phSubQuery As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DRMGetUnboundLicenseObject = ctypes.windll.msdrm.DRMGetUnboundLicenseObject
DRMGetUnboundLicenseObject.restype = ctypes.c_int
DRMGetUnboundLicenseObject.argtypes = [
    wintypes.DWORD,  # hQueryRoot : DWORD
    wintypes.LPCWSTR,  # wszSubObjectType : LPWSTR
    wintypes.DWORD,  # iIndex : DWORD
    ctypes.POINTER(wintypes.DWORD),  # phSubQuery : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msdrm.dll')
DRMGetUnboundLicenseObject = Fiddle::Function.new(
  lib['DRMGetUnboundLicenseObject'],
  [
    -Fiddle::TYPE_INT,  # hQueryRoot : DWORD
    Fiddle::TYPE_VOIDP,  # wszSubObjectType : LPWSTR
    -Fiddle::TYPE_INT,  # iIndex : DWORD
    Fiddle::TYPE_VOIDP,  # phSubQuery : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "msdrm")]
extern "system" {
    fn DRMGetUnboundLicenseObject(
        hQueryRoot: u32,  // DWORD
        wszSubObjectType: *mut u16,  // LPWSTR
        iIndex: u32,  // DWORD
        phSubQuery: *mut u32  // DWORD* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msdrm.dll")]
public static extern int DRMGetUnboundLicenseObject(uint hQueryRoot, [MarshalAs(UnmanagedType.LPWStr)] string wszSubObjectType, uint iIndex, ref uint phSubQuery);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msdrm_DRMGetUnboundLicenseObject' -Namespace Win32 -PassThru
# $api::DRMGetUnboundLicenseObject(hQueryRoot, wszSubObjectType, iIndex, phSubQuery)
#uselib "msdrm.dll"
#func global DRMGetUnboundLicenseObject "DRMGetUnboundLicenseObject" sptr, sptr, sptr, sptr
; DRMGetUnboundLicenseObject hQueryRoot, wszSubObjectType, iIndex, varptr(phSubQuery)   ; 戻り値は stat
; hQueryRoot : DWORD -> "sptr"
; wszSubObjectType : LPWSTR -> "sptr"
; iIndex : DWORD -> "sptr"
; phSubQuery : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msdrm.dll"
#cfunc global DRMGetUnboundLicenseObject "DRMGetUnboundLicenseObject" int, wstr, int, var
; res = DRMGetUnboundLicenseObject(hQueryRoot, wszSubObjectType, iIndex, phSubQuery)
; hQueryRoot : DWORD -> "int"
; wszSubObjectType : LPWSTR -> "wstr"
; iIndex : DWORD -> "int"
; phSubQuery : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT DRMGetUnboundLicenseObject(DWORD hQueryRoot, LPWSTR wszSubObjectType, DWORD iIndex, DWORD* phSubQuery)
#uselib "msdrm.dll"
#cfunc global DRMGetUnboundLicenseObject "DRMGetUnboundLicenseObject" int, wstr, int, var
; res = DRMGetUnboundLicenseObject(hQueryRoot, wszSubObjectType, iIndex, phSubQuery)
; hQueryRoot : DWORD -> "int"
; wszSubObjectType : LPWSTR -> "wstr"
; iIndex : DWORD -> "int"
; phSubQuery : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msdrm = windows.NewLazySystemDLL("msdrm.dll")
	procDRMGetUnboundLicenseObject = msdrm.NewProc("DRMGetUnboundLicenseObject")
)

// hQueryRoot (DWORD), wszSubObjectType (LPWSTR), iIndex (DWORD), phSubQuery (DWORD* in/out)
r1, _, err := procDRMGetUnboundLicenseObject.Call(
	uintptr(hQueryRoot),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszSubObjectType))),
	uintptr(iIndex),
	uintptr(phSubQuery),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function DRMGetUnboundLicenseObject(
  hQueryRoot: DWORD;   // DWORD
  wszSubObjectType: PWideChar;   // LPWSTR
  iIndex: DWORD;   // DWORD
  phSubQuery: Pointer   // DWORD* in/out
): Integer; stdcall;
  external 'msdrm.dll' name 'DRMGetUnboundLicenseObject';
result := DllCall("msdrm\DRMGetUnboundLicenseObject"
    , "UInt", hQueryRoot   ; DWORD
    , "WStr", wszSubObjectType   ; LPWSTR
    , "UInt", iIndex   ; DWORD
    , "Ptr", phSubQuery   ; DWORD* in/out
    , "Int")   ; return: HRESULT
●DRMGetUnboundLicenseObject(hQueryRoot, wszSubObjectType, iIndex, phSubQuery) = DLL("msdrm.dll", "int DRMGetUnboundLicenseObject(dword, char*, dword, void*)")
# 呼び出し: DRMGetUnboundLicenseObject(hQueryRoot, wszSubObjectType, iIndex, phSubQuery)
# hQueryRoot : DWORD -> "dword"
# wszSubObjectType : LPWSTR -> "char*"
# iIndex : DWORD -> "dword"
# phSubQuery : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "msdrm" fn DRMGetUnboundLicenseObject(
    hQueryRoot: u32, // DWORD
    wszSubObjectType: [*c]const u16, // LPWSTR
    iIndex: u32, // DWORD
    phSubQuery: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;
proc DRMGetUnboundLicenseObject(
    hQueryRoot: uint32,  # DWORD
    wszSubObjectType: WideCString,  # LPWSTR
    iIndex: uint32,  # DWORD
    phSubQuery: ptr uint32  # DWORD* in/out
): int32 {.importc: "DRMGetUnboundLicenseObject", stdcall, dynlib: "msdrm.dll".}
pragma(lib, "msdrm");
extern(Windows)
int DRMGetUnboundLicenseObject(
    uint hQueryRoot,   // DWORD
    const(wchar)* wszSubObjectType,   // LPWSTR
    uint iIndex,   // DWORD
    uint* phSubQuery   // DWORD* in/out
);
ccall((:DRMGetUnboundLicenseObject, "msdrm.dll"), stdcall, Int32,
      (UInt32, Cwstring, UInt32, Ptr{UInt32}),
      hQueryRoot, wszSubObjectType, iIndex, phSubQuery)
# hQueryRoot : DWORD -> UInt32
# wszSubObjectType : LPWSTR -> Cwstring
# iIndex : DWORD -> UInt32
# phSubQuery : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t DRMGetUnboundLicenseObject(
    uint32_t hQueryRoot,
    const uint16_t* wszSubObjectType,
    uint32_t iIndex,
    uint32_t* phSubQuery);
]]
local msdrm = ffi.load("msdrm")
-- msdrm.DRMGetUnboundLicenseObject(hQueryRoot, wszSubObjectType, iIndex, phSubQuery)
-- hQueryRoot : DWORD
-- wszSubObjectType : LPWSTR
-- iIndex : DWORD
-- phSubQuery : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('msdrm.dll');
const DRMGetUnboundLicenseObject = lib.func('__stdcall', 'DRMGetUnboundLicenseObject', 'int32_t', ['uint32_t', 'str16', 'uint32_t', 'uint32_t *']);
// DRMGetUnboundLicenseObject(hQueryRoot, wszSubObjectType, iIndex, phSubQuery)
// hQueryRoot : DWORD -> 'uint32_t'
// wszSubObjectType : LPWSTR -> 'str16'
// iIndex : DWORD -> 'uint32_t'
// phSubQuery : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("msdrm.dll", {
  DRMGetUnboundLicenseObject: { parameters: ["u32", "buffer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.DRMGetUnboundLicenseObject(hQueryRoot, wszSubObjectType, iIndex, phSubQuery)
// hQueryRoot : DWORD -> "u32"
// wszSubObjectType : LPWSTR -> "buffer"
// iIndex : DWORD -> "u32"
// phSubQuery : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t DRMGetUnboundLicenseObject(
    uint32_t hQueryRoot,
    const uint16_t* wszSubObjectType,
    uint32_t iIndex,
    uint32_t* phSubQuery);
C, "msdrm.dll");
// $ffi->DRMGetUnboundLicenseObject(hQueryRoot, wszSubObjectType, iIndex, phSubQuery);
// hQueryRoot : DWORD
// wszSubObjectType : LPWSTR
// iIndex : DWORD
// phSubQuery : 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 DRMGetUnboundLicenseObject(
        int hQueryRoot,   // DWORD
        WString wszSubObjectType,   // LPWSTR
        int iIndex,   // DWORD
        IntByReference phSubQuery   // DWORD* in/out
    );
}
@[Link("msdrm")]
lib Libmsdrm
  fun DRMGetUnboundLicenseObject = DRMGetUnboundLicenseObject(
    hQueryRoot : UInt32,   # DWORD
    wszSubObjectType : UInt16*,   # LPWSTR
    iIndex : UInt32,   # DWORD
    phSubQuery : 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 DRMGetUnboundLicenseObjectNative = Int32 Function(Uint32, Pointer<Utf16>, Uint32, Pointer<Uint32>);
typedef DRMGetUnboundLicenseObjectDart = int Function(int, Pointer<Utf16>, int, Pointer<Uint32>);
final DRMGetUnboundLicenseObject = DynamicLibrary.open('msdrm.dll')
    .lookupFunction<DRMGetUnboundLicenseObjectNative, DRMGetUnboundLicenseObjectDart>('DRMGetUnboundLicenseObject');
// hQueryRoot : DWORD -> Uint32
// wszSubObjectType : LPWSTR -> Pointer<Utf16>
// iIndex : DWORD -> Uint32
// phSubQuery : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function DRMGetUnboundLicenseObject(
  hQueryRoot: DWORD;   // DWORD
  wszSubObjectType: PWideChar;   // LPWSTR
  iIndex: DWORD;   // DWORD
  phSubQuery: Pointer   // DWORD* in/out
): Integer; stdcall;
  external 'msdrm.dll' name 'DRMGetUnboundLicenseObject';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DRMGetUnboundLicenseObject"
  c_DRMGetUnboundLicenseObject :: Word32 -> CWString -> Word32 -> Ptr Word32 -> IO Int32
-- hQueryRoot : DWORD -> Word32
-- wszSubObjectType : LPWSTR -> CWString
-- iIndex : DWORD -> Word32
-- phSubQuery : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let drmgetunboundlicenseobject =
  foreign "DRMGetUnboundLicenseObject"
    (uint32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* hQueryRoot : DWORD -> uint32_t *)
(* wszSubObjectType : LPWSTR -> (ptr uint16_t) *)
(* iIndex : DWORD -> uint32_t *)
(* phSubQuery : 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 ("DRMGetUnboundLicenseObject" drmget-unbound-license-object :convention :stdcall) :int32
  (h-query-root :uint32)   ; DWORD
  (wsz-sub-object-type (:string :encoding :utf-16le))   ; LPWSTR
  (i-index :uint32)   ; DWORD
  (ph-sub-query :pointer))   ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DRMGetUnboundLicenseObject = Win32::API::More->new('msdrm',
    'int DRMGetUnboundLicenseObject(DWORD hQueryRoot, LPCWSTR wszSubObjectType, DWORD iIndex, LPVOID phSubQuery)');
# my $ret = $DRMGetUnboundLicenseObject->Call($hQueryRoot, $wszSubObjectType, $iIndex, $phSubQuery);
# hQueryRoot : DWORD -> DWORD
# wszSubObjectType : LPWSTR -> LPCWSTR
# iIndex : DWORD -> DWORD
# phSubQuery : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。