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発行ライセンスを示すUnicode文字列。NULL可。
puServiceURLLengthDWORD*inout入力時にバッファ長、出力時に必要長を示すポインタ。
wszServiceURLLPWSTRoutoptional取得したサービスURLを受け取る出力バッファ。NULLでサイズ問い合わせ可。

戻り値の型: 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)。
const std = @import("std");

extern "msdrm" fn DRMGetServiceLocation(
    hClient: u32, // DWORD
    uServiceType: u32, // DWORD
    uServiceLocation: u32, // DWORD
    wszIssuanceLicense: [*c]const u16, // LPWSTR optional
    puServiceURLLength: [*c]u32, // DWORD* in/out
    wszServiceURL: [*c]u16 // LPWSTR optional, out
) callconv(std.os.windows.WINAPI) i32;
proc DRMGetServiceLocation(
    hClient: uint32,  # DWORD
    uServiceType: uint32,  # DWORD
    uServiceLocation: uint32,  # DWORD
    wszIssuanceLicense: WideCString,  # LPWSTR optional
    puServiceURLLength: ptr uint32,  # DWORD* in/out
    wszServiceURL: ptr uint16  # LPWSTR optional, out
): int32 {.importc: "DRMGetServiceLocation", stdcall, dynlib: "msdrm.dll".}
pragma(lib, "msdrm");
extern(Windows)
int DRMGetServiceLocation(
    uint hClient,   // DWORD
    uint uServiceType,   // DWORD
    uint uServiceLocation,   // DWORD
    const(wchar)* wszIssuanceLicense,   // LPWSTR optional
    uint* puServiceURLLength,   // DWORD* in/out
    wchar* wszServiceURL   // LPWSTR optional, out
);
ccall((:DRMGetServiceLocation, "msdrm.dll"), stdcall, Int32,
      (UInt32, UInt32, UInt32, Cwstring, Ptr{UInt32}, Ptr{UInt16}),
      hClient, uServiceType, uServiceLocation, wszIssuanceLicense, puServiceURLLength, wszServiceURL)
# hClient : DWORD -> UInt32
# uServiceType : DWORD -> UInt32
# uServiceLocation : DWORD -> UInt32
# wszIssuanceLicense : LPWSTR optional -> Cwstring
# puServiceURLLength : DWORD* in/out -> Ptr{UInt32}
# wszServiceURL : LPWSTR optional, out -> Ptr{UInt16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t DRMGetServiceLocation(
    uint32_t hClient,
    uint32_t uServiceType,
    uint32_t uServiceLocation,
    const uint16_t* wszIssuanceLicense,
    uint32_t* puServiceURLLength,
    uint16_t* wszServiceURL);
]]
local msdrm = ffi.load("msdrm")
-- msdrm.DRMGetServiceLocation(hClient, uServiceType, uServiceLocation, wszIssuanceLicense, puServiceURLLength, wszServiceURL)
-- hClient : DWORD
-- uServiceType : DWORD
-- uServiceLocation : DWORD
-- wszIssuanceLicense : LPWSTR optional
-- puServiceURLLength : DWORD* in/out
-- wszServiceURL : LPWSTR optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('msdrm.dll');
const DRMGetServiceLocation = lib.func('__stdcall', 'DRMGetServiceLocation', 'int32_t', ['uint32_t', 'uint32_t', 'uint32_t', 'str16', 'uint32_t *', 'uint16_t *']);
// DRMGetServiceLocation(hClient, uServiceType, uServiceLocation, wszIssuanceLicense, puServiceURLLength, wszServiceURL)
// hClient : DWORD -> 'uint32_t'
// uServiceType : DWORD -> 'uint32_t'
// uServiceLocation : DWORD -> 'uint32_t'
// wszIssuanceLicense : LPWSTR optional -> 'str16'
// puServiceURLLength : DWORD* in/out -> 'uint32_t *'
// wszServiceURL : LPWSTR optional, out -> 'uint16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("msdrm.dll", {
  DRMGetServiceLocation: { parameters: ["u32", "u32", "u32", "buffer", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.DRMGetServiceLocation(hClient, uServiceType, uServiceLocation, wszIssuanceLicense, puServiceURLLength, wszServiceURL)
// hClient : DWORD -> "u32"
// uServiceType : DWORD -> "u32"
// uServiceLocation : DWORD -> "u32"
// wszIssuanceLicense : LPWSTR optional -> "buffer"
// puServiceURLLength : DWORD* in/out -> "pointer"
// wszServiceURL : LPWSTR optional, out -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t DRMGetServiceLocation(
    uint32_t hClient,
    uint32_t uServiceType,
    uint32_t uServiceLocation,
    const uint16_t* wszIssuanceLicense,
    uint32_t* puServiceURLLength,
    uint16_t* wszServiceURL);
C, "msdrm.dll");
// $ffi->DRMGetServiceLocation(hClient, uServiceType, uServiceLocation, wszIssuanceLicense, puServiceURLLength, wszServiceURL);
// hClient : DWORD
// uServiceType : DWORD
// uServiceLocation : DWORD
// wszIssuanceLicense : LPWSTR optional
// puServiceURLLength : DWORD* in/out
// wszServiceURL : LPWSTR optional, out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Msdrm extends StdCallLibrary {
    Msdrm INSTANCE = Native.load("msdrm", Msdrm.class);
    int DRMGetServiceLocation(
        int hClient,   // DWORD
        int uServiceType,   // DWORD
        int uServiceLocation,   // DWORD
        WString wszIssuanceLicense,   // LPWSTR optional
        IntByReference puServiceURLLength,   // DWORD* in/out
        char[] wszServiceURL   // LPWSTR optional, out
    );
}
@[Link("msdrm")]
lib Libmsdrm
  fun DRMGetServiceLocation = DRMGetServiceLocation(
    hClient : UInt32,   # DWORD
    uServiceType : UInt32,   # DWORD
    uServiceLocation : UInt32,   # DWORD
    wszIssuanceLicense : UInt16*,   # LPWSTR optional
    puServiceURLLength : UInt32*,   # DWORD* in/out
    wszServiceURL : UInt16*   # LPWSTR optional, out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef DRMGetServiceLocationNative = Int32 Function(Uint32, Uint32, Uint32, Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>);
typedef DRMGetServiceLocationDart = int Function(int, int, int, Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>);
final DRMGetServiceLocation = DynamicLibrary.open('msdrm.dll')
    .lookupFunction<DRMGetServiceLocationNative, DRMGetServiceLocationDart>('DRMGetServiceLocation');
// hClient : DWORD -> Uint32
// uServiceType : DWORD -> Uint32
// uServiceLocation : DWORD -> Uint32
// wszIssuanceLicense : LPWSTR optional -> Pointer<Utf16>
// puServiceURLLength : DWORD* in/out -> Pointer<Uint32>
// wszServiceURL : LPWSTR optional, out -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DRMGetServiceLocation"
  c_DRMGetServiceLocation :: Word32 -> Word32 -> Word32 -> CWString -> Ptr Word32 -> CWString -> IO Int32
-- hClient : DWORD -> Word32
-- uServiceType : DWORD -> Word32
-- uServiceLocation : DWORD -> Word32
-- wszIssuanceLicense : LPWSTR optional -> CWString
-- puServiceURLLength : DWORD* in/out -> Ptr Word32
-- wszServiceURL : LPWSTR optional, out -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let drmgetservicelocation =
  foreign "DRMGetServiceLocation"
    (uint32_t @-> uint32_t @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hClient : DWORD -> uint32_t *)
(* uServiceType : DWORD -> uint32_t *)
(* uServiceLocation : DWORD -> uint32_t *)
(* wszIssuanceLicense : LPWSTR optional -> (ptr uint16_t) *)
(* puServiceURLLength : DWORD* in/out -> (ptr uint32_t) *)
(* wszServiceURL : LPWSTR optional, out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msdrm (t "msdrm.dll"))
(cffi:use-foreign-library msdrm)

(cffi:defcfun ("DRMGetServiceLocation" drmget-service-location :convention :stdcall) :int32
  (h-client :uint32)   ; DWORD
  (u-service-type :uint32)   ; DWORD
  (u-service-location :uint32)   ; DWORD
  (wsz-issuance-license (:string :encoding :utf-16le))   ; LPWSTR optional
  (pu-service-urllength :pointer)   ; DWORD* in/out
  (wsz-service-url :pointer))   ; LPWSTR optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DRMGetServiceLocation = Win32::API::More->new('msdrm',
    'int DRMGetServiceLocation(DWORD hClient, DWORD uServiceType, DWORD uServiceLocation, LPCWSTR wszIssuanceLicense, LPVOID puServiceURLLength, LPWSTR wszServiceURL)');
# my $ret = $DRMGetServiceLocation->Call($hClient, $uServiceType, $uServiceLocation, $wszIssuanceLicense, $puServiceURLLength, $wszServiceURL);
# hClient : DWORD -> DWORD
# uServiceType : DWORD -> DWORD
# uServiceLocation : DWORD -> DWORD
# wszIssuanceLicense : LPWSTR optional -> LPCWSTR
# puServiceURLLength : DWORD* in/out -> LPVOID
# wszServiceURL : LPWSTR optional, out -> LPWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。