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

DRMLoadLibrary

関数
RMS環境にプラグインライブラリを読み込む。
DLLmsdrm.dll呼出規約winapi

シグネチャ

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

HRESULT DRMLoadLibrary(
    DWORD hEnv,
    DRMSPECTYPE eSpecification,
    LPWSTR wszLibraryProvider,
    LPWSTR wszCredentials,   // optional
    DWORD* phLibrary
);

パラメーター

名前方向
hEnvDWORDin
eSpecificationDRMSPECTYPEin
wszLibraryProviderLPWSTRin
wszCredentialsLPWSTRinoptional
phLibraryDWORD*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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // HRESULT
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';
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)。