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

DRMCreateClientSession

関数
RMSのクライアントセッションを作成する。
DLLmsdrm.dll呼出規約winapi

シグネチャ

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

HRESULT DRMCreateClientSession(
    DRMCALLBACK pfnCallback,
    DWORD uCallbackVersion,
    LPWSTR wszGroupIDProviderType,
    LPWSTR wszGroupID,   // optional
    DWORD* phClient
);

パラメーター

名前方向
pfnCallbackDRMCALLBACKin
uCallbackVersionDWORDin
wszGroupIDProviderTypeLPWSTRin
wszGroupIDLPWSTRinoptional
phClientDWORD*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

DRMCreateClientSession = ctypes.windll.msdrm.DRMCreateClientSession
DRMCreateClientSession.restype = ctypes.c_int
DRMCreateClientSession.argtypes = [
    ctypes.c_void_p,  # pfnCallback : DRMCALLBACK
    wintypes.DWORD,  # uCallbackVersion : DWORD
    wintypes.LPCWSTR,  # wszGroupIDProviderType : LPWSTR
    wintypes.LPCWSTR,  # wszGroupID : LPWSTR optional
    ctypes.POINTER(wintypes.DWORD),  # phClient : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msdrm = windows.NewLazySystemDLL("msdrm.dll")
	procDRMCreateClientSession = msdrm.NewProc("DRMCreateClientSession")
)

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