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

DRMGetServiceLocation

関数
RMSサービスのURL(場所)を取得する。
DLLmsdrm.dll呼出規約winapi

シグネチャ

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

HRESULT DRMGetServiceLocation(
    DWORD hClient,
    DWORD uServiceType,
    DWORD uServiceLocation,
    LPWSTR wszIssuanceLicense,   // optional
    DWORD* puServiceURLLength,
    LPWSTR wszServiceURL   // optional
);

パラメーター

名前方向
hClientDWORDin
uServiceTypeDWORDin
uServiceLocationDWORDin
wszIssuanceLicenseLPWSTRinoptional
puServiceURLLengthDWORD*inout
wszServiceURLLPWSTRoutoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DRMGetServiceLocation(
    DWORD hClient,
    DWORD uServiceType,
    DWORD uServiceLocation,
    LPWSTR wszIssuanceLicense,   // optional
    DWORD* puServiceURLLength,
    LPWSTR wszServiceURL   // optional
);
[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMGetServiceLocation(
    uint hClient,   // DWORD
    uint uServiceType,   // DWORD
    uint uServiceLocation,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string wszIssuanceLicense,   // LPWSTR optional
    ref uint puServiceURLLength,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wszServiceURL   // LPWSTR optional, out
);
<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMGetServiceLocation(
    hClient As UInteger,   ' DWORD
    uServiceType As UInteger,   ' DWORD
    uServiceLocation As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> wszIssuanceLicense As String,   ' LPWSTR optional
    ByRef puServiceURLLength As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> wszServiceURL As System.Text.StringBuilder   ' LPWSTR optional, out
) As Integer
End Function
' hClient : DWORD
' uServiceType : DWORD
' uServiceLocation : DWORD
' wszIssuanceLicense : LPWSTR optional
' puServiceURLLength : DWORD* in/out
' wszServiceURL : LPWSTR optional, out
Declare PtrSafe Function DRMGetServiceLocation Lib "msdrm" ( _
    ByVal hClient As Long, _
    ByVal uServiceType As Long, _
    ByVal uServiceLocation As Long, _
    ByVal wszIssuanceLicense As LongPtr, _
    ByRef puServiceURLLength As Long, _
    ByVal wszServiceURL As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DRMGetServiceLocation = ctypes.windll.msdrm.DRMGetServiceLocation
DRMGetServiceLocation.restype = ctypes.c_int
DRMGetServiceLocation.argtypes = [
    wintypes.DWORD,  # hClient : DWORD
    wintypes.DWORD,  # uServiceType : DWORD
    wintypes.DWORD,  # uServiceLocation : DWORD
    wintypes.LPCWSTR,  # wszIssuanceLicense : LPWSTR optional
    ctypes.POINTER(wintypes.DWORD),  # puServiceURLLength : DWORD* in/out
    wintypes.LPWSTR,  # wszServiceURL : LPWSTR optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msdrm = windows.NewLazySystemDLL("msdrm.dll")
	procDRMGetServiceLocation = msdrm.NewProc("DRMGetServiceLocation")
)

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