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

DRMDuplicateSession

関数
RMSのセッションを複製する。
DLLmsdrm.dll呼出規約winapi

シグネチャ

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

HRESULT DRMDuplicateSession(
    DWORD hSessionIn,
    DWORD* phSessionOut
);

パラメーター

名前方向
hSessionInDWORDin
phSessionOutDWORD*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

DRMDuplicateSession = ctypes.windll.msdrm.DRMDuplicateSession
DRMDuplicateSession.restype = ctypes.c_int
DRMDuplicateSession.argtypes = [
    wintypes.DWORD,  # hSessionIn : DWORD
    ctypes.POINTER(wintypes.DWORD),  # phSessionOut : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msdrm = windows.NewLazySystemDLL("msdrm.dll")
	procDRMDuplicateSession = msdrm.NewProc("DRMDuplicateSession")
)

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