ホーム › Data.RightsManagement › DRMCreateEnablingPrincipal
DRMCreateEnablingPrincipal
関数RMSの有効化プリンシパルを作成する。
シグネチャ
// msdrm.dll
#include <windows.h>
HRESULT DRMCreateEnablingPrincipal(
DWORD hEnv,
DWORD hLibrary,
LPWSTR wszObject,
DRMID* pidPrincipal,
LPWSTR wszCredentials,
DWORD* phEnablingPrincipal
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hEnv | DWORD | in |
| hLibrary | DWORD | in |
| wszObject | LPWSTR | in |
| pidPrincipal | DRMID* | inout |
| wszCredentials | LPWSTR | in |
| phEnablingPrincipal | DWORD* | inout |
戻り値の型: HRESULT
各言語での呼び出し定義
// msdrm.dll
#include <windows.h>
HRESULT DRMCreateEnablingPrincipal(
DWORD hEnv,
DWORD hLibrary,
LPWSTR wszObject,
DRMID* pidPrincipal,
LPWSTR wszCredentials,
DWORD* phEnablingPrincipal
);[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMCreateEnablingPrincipal(
uint hEnv, // DWORD
uint hLibrary, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string wszObject, // LPWSTR
IntPtr pidPrincipal, // DRMID* in/out
[MarshalAs(UnmanagedType.LPWStr)] string wszCredentials, // LPWSTR
ref uint phEnablingPrincipal // DWORD* in/out
);<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMCreateEnablingPrincipal(
hEnv As UInteger, ' DWORD
hLibrary As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> wszObject As String, ' LPWSTR
pidPrincipal As IntPtr, ' DRMID* in/out
<MarshalAs(UnmanagedType.LPWStr)> wszCredentials As String, ' LPWSTR
ByRef phEnablingPrincipal As UInteger ' DWORD* in/out
) As Integer
End Function' hEnv : DWORD
' hLibrary : DWORD
' wszObject : LPWSTR
' pidPrincipal : DRMID* in/out
' wszCredentials : LPWSTR
' phEnablingPrincipal : DWORD* in/out
Declare PtrSafe Function DRMCreateEnablingPrincipal Lib "msdrm" ( _
ByVal hEnv As Long, _
ByVal hLibrary As Long, _
ByVal wszObject As LongPtr, _
ByVal pidPrincipal As LongPtr, _
ByVal wszCredentials As LongPtr, _
ByRef phEnablingPrincipal As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DRMCreateEnablingPrincipal = ctypes.windll.msdrm.DRMCreateEnablingPrincipal
DRMCreateEnablingPrincipal.restype = ctypes.c_int
DRMCreateEnablingPrincipal.argtypes = [
wintypes.DWORD, # hEnv : DWORD
wintypes.DWORD, # hLibrary : DWORD
wintypes.LPCWSTR, # wszObject : LPWSTR
ctypes.c_void_p, # pidPrincipal : DRMID* in/out
wintypes.LPCWSTR, # wszCredentials : LPWSTR
ctypes.POINTER(wintypes.DWORD), # phEnablingPrincipal : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msdrm.dll')
DRMCreateEnablingPrincipal = Fiddle::Function.new(
lib['DRMCreateEnablingPrincipal'],
[
-Fiddle::TYPE_INT, # hEnv : DWORD
-Fiddle::TYPE_INT, # hLibrary : DWORD
Fiddle::TYPE_VOIDP, # wszObject : LPWSTR
Fiddle::TYPE_VOIDP, # pidPrincipal : DRMID* in/out
Fiddle::TYPE_VOIDP, # wszCredentials : LPWSTR
Fiddle::TYPE_VOIDP, # phEnablingPrincipal : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "msdrm")]
extern "system" {
fn DRMCreateEnablingPrincipal(
hEnv: u32, // DWORD
hLibrary: u32, // DWORD
wszObject: *mut u16, // LPWSTR
pidPrincipal: *mut DRMID, // DRMID* in/out
wszCredentials: *mut u16, // LPWSTR
phEnablingPrincipal: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msdrm.dll")]
public static extern int DRMCreateEnablingPrincipal(uint hEnv, uint hLibrary, [MarshalAs(UnmanagedType.LPWStr)] string wszObject, IntPtr pidPrincipal, [MarshalAs(UnmanagedType.LPWStr)] string wszCredentials, ref uint phEnablingPrincipal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msdrm_DRMCreateEnablingPrincipal' -Namespace Win32 -PassThru
# $api::DRMCreateEnablingPrincipal(hEnv, hLibrary, wszObject, pidPrincipal, wszCredentials, phEnablingPrincipal)#uselib "msdrm.dll"
#func global DRMCreateEnablingPrincipal "DRMCreateEnablingPrincipal" sptr, sptr, sptr, sptr, sptr, sptr
; DRMCreateEnablingPrincipal hEnv, hLibrary, wszObject, varptr(pidPrincipal), wszCredentials, varptr(phEnablingPrincipal) ; 戻り値は stat
; hEnv : DWORD -> "sptr"
; hLibrary : DWORD -> "sptr"
; wszObject : LPWSTR -> "sptr"
; pidPrincipal : DRMID* in/out -> "sptr"
; wszCredentials : LPWSTR -> "sptr"
; phEnablingPrincipal : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msdrm.dll" #cfunc global DRMCreateEnablingPrincipal "DRMCreateEnablingPrincipal" int, int, wstr, var, wstr, var ; res = DRMCreateEnablingPrincipal(hEnv, hLibrary, wszObject, pidPrincipal, wszCredentials, phEnablingPrincipal) ; hEnv : DWORD -> "int" ; hLibrary : DWORD -> "int" ; wszObject : LPWSTR -> "wstr" ; pidPrincipal : DRMID* in/out -> "var" ; wszCredentials : LPWSTR -> "wstr" ; phEnablingPrincipal : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msdrm.dll" #cfunc global DRMCreateEnablingPrincipal "DRMCreateEnablingPrincipal" int, int, wstr, sptr, wstr, sptr ; res = DRMCreateEnablingPrincipal(hEnv, hLibrary, wszObject, varptr(pidPrincipal), wszCredentials, varptr(phEnablingPrincipal)) ; hEnv : DWORD -> "int" ; hLibrary : DWORD -> "int" ; wszObject : LPWSTR -> "wstr" ; pidPrincipal : DRMID* in/out -> "sptr" ; wszCredentials : LPWSTR -> "wstr" ; phEnablingPrincipal : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DRMCreateEnablingPrincipal(DWORD hEnv, DWORD hLibrary, LPWSTR wszObject, DRMID* pidPrincipal, LPWSTR wszCredentials, DWORD* phEnablingPrincipal) #uselib "msdrm.dll" #cfunc global DRMCreateEnablingPrincipal "DRMCreateEnablingPrincipal" int, int, wstr, var, wstr, var ; res = DRMCreateEnablingPrincipal(hEnv, hLibrary, wszObject, pidPrincipal, wszCredentials, phEnablingPrincipal) ; hEnv : DWORD -> "int" ; hLibrary : DWORD -> "int" ; wszObject : LPWSTR -> "wstr" ; pidPrincipal : DRMID* in/out -> "var" ; wszCredentials : LPWSTR -> "wstr" ; phEnablingPrincipal : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DRMCreateEnablingPrincipal(DWORD hEnv, DWORD hLibrary, LPWSTR wszObject, DRMID* pidPrincipal, LPWSTR wszCredentials, DWORD* phEnablingPrincipal) #uselib "msdrm.dll" #cfunc global DRMCreateEnablingPrincipal "DRMCreateEnablingPrincipal" int, int, wstr, intptr, wstr, intptr ; res = DRMCreateEnablingPrincipal(hEnv, hLibrary, wszObject, varptr(pidPrincipal), wszCredentials, varptr(phEnablingPrincipal)) ; hEnv : DWORD -> "int" ; hLibrary : DWORD -> "int" ; wszObject : LPWSTR -> "wstr" ; pidPrincipal : DRMID* in/out -> "intptr" ; wszCredentials : LPWSTR -> "wstr" ; phEnablingPrincipal : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msdrm = windows.NewLazySystemDLL("msdrm.dll")
procDRMCreateEnablingPrincipal = msdrm.NewProc("DRMCreateEnablingPrincipal")
)
// hEnv (DWORD), hLibrary (DWORD), wszObject (LPWSTR), pidPrincipal (DRMID* in/out), wszCredentials (LPWSTR), phEnablingPrincipal (DWORD* in/out)
r1, _, err := procDRMCreateEnablingPrincipal.Call(
uintptr(hEnv),
uintptr(hLibrary),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszObject))),
uintptr(pidPrincipal),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszCredentials))),
uintptr(phEnablingPrincipal),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DRMCreateEnablingPrincipal(
hEnv: DWORD; // DWORD
hLibrary: DWORD; // DWORD
wszObject: PWideChar; // LPWSTR
pidPrincipal: Pointer; // DRMID* in/out
wszCredentials: PWideChar; // LPWSTR
phEnablingPrincipal: Pointer // DWORD* in/out
): Integer; stdcall;
external 'msdrm.dll' name 'DRMCreateEnablingPrincipal';result := DllCall("msdrm\DRMCreateEnablingPrincipal"
, "UInt", hEnv ; DWORD
, "UInt", hLibrary ; DWORD
, "WStr", wszObject ; LPWSTR
, "Ptr", pidPrincipal ; DRMID* in/out
, "WStr", wszCredentials ; LPWSTR
, "Ptr", phEnablingPrincipal ; DWORD* in/out
, "Int") ; return: HRESULT●DRMCreateEnablingPrincipal(hEnv, hLibrary, wszObject, pidPrincipal, wszCredentials, phEnablingPrincipal) = DLL("msdrm.dll", "int DRMCreateEnablingPrincipal(dword, dword, char*, void*, char*, void*)")
# 呼び出し: DRMCreateEnablingPrincipal(hEnv, hLibrary, wszObject, pidPrincipal, wszCredentials, phEnablingPrincipal)
# hEnv : DWORD -> "dword"
# hLibrary : DWORD -> "dword"
# wszObject : LPWSTR -> "char*"
# pidPrincipal : DRMID* in/out -> "void*"
# wszCredentials : LPWSTR -> "char*"
# phEnablingPrincipal : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。