ホーム › Data.RightsManagement › DRMLoadLibrary
DRMLoadLibrary
関数RMS環境にプラグインライブラリを読み込む。
シグネチャ
// msdrm.dll
#include <windows.h>
HRESULT DRMLoadLibrary(
DWORD hEnv,
DRMSPECTYPE eSpecification,
LPWSTR wszLibraryProvider,
LPWSTR wszCredentials, // optional
DWORD* phLibrary
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hEnv | DWORD | in | 対象の環境ハンドル。DRMInitEnvironmentで取得したもの。 |
| eSpecification | DRMSPECTYPE | in | ライブラリの仕様種別を示すDRMSPECTYPE。 |
| wszLibraryProvider | LPWSTR | in | 読み込むライブラリプロバイダー名を示すUnicode文字列。 |
| wszCredentials | LPWSTR | inoptional | ライブラリ読み込みに用いる資格情報を示すUnicode文字列。 |
| phLibrary | DWORD* | inout | 読み込んだライブラリのハンドルを受け取る出力先。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// msdrm.dll
#include <windows.h>
HRESULT DRMLoadLibrary(
DWORD hEnv,
DRMSPECTYPE eSpecification,
LPWSTR wszLibraryProvider,
LPWSTR wszCredentials, // optional
DWORD* phLibrary
);[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMLoadLibrary(
uint hEnv, // DWORD
int eSpecification, // DRMSPECTYPE
[MarshalAs(UnmanagedType.LPWStr)] string wszLibraryProvider, // LPWSTR
[MarshalAs(UnmanagedType.LPWStr)] string wszCredentials, // LPWSTR optional
ref uint phLibrary // DWORD* in/out
);<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMLoadLibrary(
hEnv As UInteger, ' DWORD
eSpecification As Integer, ' DRMSPECTYPE
<MarshalAs(UnmanagedType.LPWStr)> wszLibraryProvider As String, ' LPWSTR
<MarshalAs(UnmanagedType.LPWStr)> wszCredentials As String, ' LPWSTR optional
ByRef phLibrary As UInteger ' DWORD* in/out
) As Integer
End Function' hEnv : DWORD
' eSpecification : DRMSPECTYPE
' wszLibraryProvider : LPWSTR
' wszCredentials : LPWSTR optional
' phLibrary : DWORD* in/out
Declare PtrSafe Function DRMLoadLibrary Lib "msdrm" ( _
ByVal hEnv As Long, _
ByVal eSpecification As Long, _
ByVal wszLibraryProvider As LongPtr, _
ByVal wszCredentials As LongPtr, _
ByRef phLibrary As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DRMLoadLibrary = ctypes.windll.msdrm.DRMLoadLibrary
DRMLoadLibrary.restype = ctypes.c_int
DRMLoadLibrary.argtypes = [
wintypes.DWORD, # hEnv : DWORD
ctypes.c_int, # eSpecification : DRMSPECTYPE
wintypes.LPCWSTR, # wszLibraryProvider : LPWSTR
wintypes.LPCWSTR, # wszCredentials : LPWSTR optional
ctypes.POINTER(wintypes.DWORD), # phLibrary : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msdrm.dll')
DRMLoadLibrary = Fiddle::Function.new(
lib['DRMLoadLibrary'],
[
-Fiddle::TYPE_INT, # hEnv : DWORD
Fiddle::TYPE_INT, # eSpecification : DRMSPECTYPE
Fiddle::TYPE_VOIDP, # wszLibraryProvider : LPWSTR
Fiddle::TYPE_VOIDP, # wszCredentials : LPWSTR optional
Fiddle::TYPE_VOIDP, # phLibrary : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "msdrm")]
extern "system" {
fn DRMLoadLibrary(
hEnv: u32, // DWORD
eSpecification: i32, // DRMSPECTYPE
wszLibraryProvider: *mut u16, // LPWSTR
wszCredentials: *mut u16, // LPWSTR optional
phLibrary: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msdrm.dll")]
public static extern int DRMLoadLibrary(uint hEnv, int eSpecification, [MarshalAs(UnmanagedType.LPWStr)] string wszLibraryProvider, [MarshalAs(UnmanagedType.LPWStr)] string wszCredentials, ref uint phLibrary);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msdrm_DRMLoadLibrary' -Namespace Win32 -PassThru
# $api::DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary)#uselib "msdrm.dll"
#func global DRMLoadLibrary "DRMLoadLibrary" sptr, sptr, sptr, sptr, sptr
; DRMLoadLibrary hEnv, eSpecification, wszLibraryProvider, wszCredentials, varptr(phLibrary) ; 戻り値は stat
; hEnv : DWORD -> "sptr"
; eSpecification : DRMSPECTYPE -> "sptr"
; wszLibraryProvider : LPWSTR -> "sptr"
; wszCredentials : LPWSTR optional -> "sptr"
; phLibrary : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msdrm.dll" #cfunc global DRMLoadLibrary "DRMLoadLibrary" int, int, wstr, wstr, var ; res = DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary) ; hEnv : DWORD -> "int" ; eSpecification : DRMSPECTYPE -> "int" ; wszLibraryProvider : LPWSTR -> "wstr" ; wszCredentials : LPWSTR optional -> "wstr" ; phLibrary : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msdrm.dll" #cfunc global DRMLoadLibrary "DRMLoadLibrary" int, int, wstr, wstr, sptr ; res = DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, varptr(phLibrary)) ; hEnv : DWORD -> "int" ; eSpecification : DRMSPECTYPE -> "int" ; wszLibraryProvider : LPWSTR -> "wstr" ; wszCredentials : LPWSTR optional -> "wstr" ; phLibrary : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DRMLoadLibrary(DWORD hEnv, DRMSPECTYPE eSpecification, LPWSTR wszLibraryProvider, LPWSTR wszCredentials, DWORD* phLibrary) #uselib "msdrm.dll" #cfunc global DRMLoadLibrary "DRMLoadLibrary" int, int, wstr, wstr, var ; res = DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary) ; hEnv : DWORD -> "int" ; eSpecification : DRMSPECTYPE -> "int" ; wszLibraryProvider : LPWSTR -> "wstr" ; wszCredentials : LPWSTR optional -> "wstr" ; phLibrary : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DRMLoadLibrary(DWORD hEnv, DRMSPECTYPE eSpecification, LPWSTR wszLibraryProvider, LPWSTR wszCredentials, DWORD* phLibrary) #uselib "msdrm.dll" #cfunc global DRMLoadLibrary "DRMLoadLibrary" int, int, wstr, wstr, intptr ; res = DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, varptr(phLibrary)) ; hEnv : DWORD -> "int" ; eSpecification : DRMSPECTYPE -> "int" ; wszLibraryProvider : LPWSTR -> "wstr" ; wszCredentials : LPWSTR optional -> "wstr" ; phLibrary : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msdrm = windows.NewLazySystemDLL("msdrm.dll")
procDRMLoadLibrary = msdrm.NewProc("DRMLoadLibrary")
)
// hEnv (DWORD), eSpecification (DRMSPECTYPE), wszLibraryProvider (LPWSTR), wszCredentials (LPWSTR optional), phLibrary (DWORD* in/out)
r1, _, err := procDRMLoadLibrary.Call(
uintptr(hEnv),
uintptr(eSpecification),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszLibraryProvider))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszCredentials))),
uintptr(phLibrary),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DRMLoadLibrary(
hEnv: DWORD; // DWORD
eSpecification: Integer; // DRMSPECTYPE
wszLibraryProvider: PWideChar; // LPWSTR
wszCredentials: PWideChar; // LPWSTR optional
phLibrary: Pointer // DWORD* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMLoadLibrary';result := DllCall("msdrm\DRMLoadLibrary"
, "UInt", hEnv ; DWORD
, "Int", eSpecification ; DRMSPECTYPE
, "WStr", wszLibraryProvider ; LPWSTR
, "WStr", wszCredentials ; LPWSTR optional
, "Ptr", phLibrary ; DWORD* in/out
, "Int") ; return: HRESULT●DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary) = DLL("msdrm.dll", "int DRMLoadLibrary(dword, int, char*, char*, void*)")
# 呼び出し: DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary)
# hEnv : DWORD -> "dword"
# eSpecification : DRMSPECTYPE -> "int"
# wszLibraryProvider : LPWSTR -> "char*"
# wszCredentials : LPWSTR optional -> "char*"
# phLibrary : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msdrm" fn DRMLoadLibrary(
hEnv: u32, // DWORD
eSpecification: i32, // DRMSPECTYPE
wszLibraryProvider: [*c]const u16, // LPWSTR
wszCredentials: [*c]const u16, // LPWSTR optional
phLibrary: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;proc DRMLoadLibrary(
hEnv: uint32, # DWORD
eSpecification: int32, # DRMSPECTYPE
wszLibraryProvider: WideCString, # LPWSTR
wszCredentials: WideCString, # LPWSTR optional
phLibrary: ptr uint32 # DWORD* in/out
): int32 {.importc: "DRMLoadLibrary", stdcall, dynlib: "msdrm.dll".}pragma(lib, "msdrm");
extern(Windows)
int DRMLoadLibrary(
uint hEnv, // DWORD
int eSpecification, // DRMSPECTYPE
const(wchar)* wszLibraryProvider, // LPWSTR
const(wchar)* wszCredentials, // LPWSTR optional
uint* phLibrary // DWORD* in/out
);ccall((:DRMLoadLibrary, "msdrm.dll"), stdcall, Int32,
(UInt32, Int32, Cwstring, Cwstring, Ptr{UInt32}),
hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary)
# hEnv : DWORD -> UInt32
# eSpecification : DRMSPECTYPE -> Int32
# wszLibraryProvider : LPWSTR -> Cwstring
# wszCredentials : LPWSTR optional -> Cwstring
# phLibrary : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DRMLoadLibrary(
uint32_t hEnv,
int32_t eSpecification,
const uint16_t* wszLibraryProvider,
const uint16_t* wszCredentials,
uint32_t* phLibrary);
]]
local msdrm = ffi.load("msdrm")
-- msdrm.DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary)
-- hEnv : DWORD
-- eSpecification : DRMSPECTYPE
-- wszLibraryProvider : LPWSTR
-- wszCredentials : LPWSTR optional
-- phLibrary : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msdrm.dll');
const DRMLoadLibrary = lib.func('__stdcall', 'DRMLoadLibrary', 'int32_t', ['uint32_t', 'int32_t', 'str16', 'str16', 'uint32_t *']);
// DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary)
// hEnv : DWORD -> 'uint32_t'
// eSpecification : DRMSPECTYPE -> 'int32_t'
// wszLibraryProvider : LPWSTR -> 'str16'
// wszCredentials : LPWSTR optional -> 'str16'
// phLibrary : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msdrm.dll", {
DRMLoadLibrary: { parameters: ["u32", "i32", "buffer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary)
// hEnv : DWORD -> "u32"
// eSpecification : DRMSPECTYPE -> "i32"
// wszLibraryProvider : LPWSTR -> "buffer"
// wszCredentials : LPWSTR optional -> "buffer"
// phLibrary : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DRMLoadLibrary(
uint32_t hEnv,
int32_t eSpecification,
const uint16_t* wszLibraryProvider,
const uint16_t* wszCredentials,
uint32_t* phLibrary);
C, "msdrm.dll");
// $ffi->DRMLoadLibrary(hEnv, eSpecification, wszLibraryProvider, wszCredentials, phLibrary);
// hEnv : DWORD
// eSpecification : DRMSPECTYPE
// wszLibraryProvider : LPWSTR
// wszCredentials : LPWSTR optional
// phLibrary : 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 DRMLoadLibrary(
int hEnv, // DWORD
int eSpecification, // DRMSPECTYPE
WString wszLibraryProvider, // LPWSTR
WString wszCredentials, // LPWSTR optional
IntByReference phLibrary // DWORD* in/out
);
}@[Link("msdrm")]
lib Libmsdrm
fun DRMLoadLibrary = DRMLoadLibrary(
hEnv : UInt32, # DWORD
eSpecification : Int32, # DRMSPECTYPE
wszLibraryProvider : UInt16*, # LPWSTR
wszCredentials : UInt16*, # LPWSTR optional
phLibrary : 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 DRMLoadLibraryNative = Int32 Function(Uint32, Int32, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
typedef DRMLoadLibraryDart = int Function(int, int, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
final DRMLoadLibrary = DynamicLibrary.open('msdrm.dll')
.lookupFunction<DRMLoadLibraryNative, DRMLoadLibraryDart>('DRMLoadLibrary');
// hEnv : DWORD -> Uint32
// eSpecification : DRMSPECTYPE -> Int32
// wszLibraryProvider : LPWSTR -> Pointer<Utf16>
// wszCredentials : LPWSTR optional -> Pointer<Utf16>
// phLibrary : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DRMLoadLibrary(
hEnv: DWORD; // DWORD
eSpecification: Integer; // DRMSPECTYPE
wszLibraryProvider: PWideChar; // LPWSTR
wszCredentials: PWideChar; // LPWSTR optional
phLibrary: Pointer // DWORD* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMLoadLibrary';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DRMLoadLibrary"
c_DRMLoadLibrary :: Word32 -> Int32 -> CWString -> CWString -> Ptr Word32 -> IO Int32
-- hEnv : DWORD -> Word32
-- eSpecification : DRMSPECTYPE -> Int32
-- wszLibraryProvider : LPWSTR -> CWString
-- wszCredentials : LPWSTR optional -> CWString
-- phLibrary : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drmloadlibrary =
foreign "DRMLoadLibrary"
(uint32_t @-> int32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* hEnv : DWORD -> uint32_t *)
(* eSpecification : DRMSPECTYPE -> int32_t *)
(* wszLibraryProvider : LPWSTR -> (ptr uint16_t) *)
(* wszCredentials : LPWSTR optional -> (ptr uint16_t) *)
(* phLibrary : 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 ("DRMLoadLibrary" drmload-library :convention :stdcall) :int32
(h-env :uint32) ; DWORD
(e-specification :int32) ; DRMSPECTYPE
(wsz-library-provider (:string :encoding :utf-16le)) ; LPWSTR
(wsz-credentials (:string :encoding :utf-16le)) ; LPWSTR optional
(ph-library :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DRMLoadLibrary = Win32::API::More->new('msdrm',
'int DRMLoadLibrary(DWORD hEnv, int eSpecification, LPCWSTR wszLibraryProvider, LPCWSTR wszCredentials, LPVOID phLibrary)');
# my $ret = $DRMLoadLibrary->Call($hEnv, $eSpecification, $wszLibraryProvider, $wszCredentials, $phLibrary);
# hEnv : DWORD -> DWORD
# eSpecification : DRMSPECTYPE -> int
# wszLibraryProvider : LPWSTR -> LPCWSTR
# wszCredentials : LPWSTR optional -> LPCWSTR
# phLibrary : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型