DRMDeleteLicense
関数シグネチャ
// msdrm.dll
#include <windows.h>
HRESULT DRMDeleteLicense(
DWORD hSession,
LPWSTR wszLicenseId
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hSession | DWORD | in | ライセンスストレージセッションまたはクライアントセッションのハンドル。ストレージセッションのハンドルを使用すると、エンドユーザーライセンスと失効リストを削除できます。クライアントセッションのハンドルを使用すると、エンドユーザーライセンス、権利アカウント証明書、クライアントライセンサー証明書、および発行ライセンステンプレートを削除できます。 ライセンスストレージセッションのハンドルは、DRMCreateLicenseStorageSession 関数を使用して取得できます。クライアントセッションのハンドルは、DRMCreateClientSession 関数を使用して取得できます。 |
| wszLicenseId | LPWSTR | in | 削除するライセンスまたはテンプレートの ID を格納した、null で終わる文字列へのポインター。ライセンス ID は、ライセンスクエリ関数と g_wszQUERY_CONTENTIDVALUE 定数を使用してクエリすることで、ライセンス XrML の ID 要素内から取得できます。テンプレート ID は GUID です。GUID は、DRMEnumerateLicense 関数を呼び出すことで列挙できます。 |
戻り値の型: HRESULT
公式ドキュメント
ライセンス、クライアントライセンサー証明書、失効リスト、または発行ライセンステンプレートを削除します。
戻り値
関数が成功した場合は、S_OK を返します。
関数が失敗した場合は、エラーを示す HRESULT 値を返します。想定される値には次のリストに示すものがありますが、これらに限定されません。一般的なエラーコードの一覧については、Common HRESULT Values を参照してください。
解説(Remarks)
AD RMS システムは、既に所有しているコンテンツの新しいライセンスや失効リストを取得する場合であっても、古いライセンスや失効リストがライセンスストアに保存されているかどうかを確認しません。そのため、ライセンスや証明書を時折削除することが重要です。この処理には時間がかかることがあるため、時々実行するか、プログラムのアイドル時間中に実行するのが適切な場合があります。
エンドユーザーライセンスを削除しても、この関数は関連する失効リストを自動的には削除しません。
コンテンツ ID を使用してライセンスを削除する場合、hSession パラメーターはクライアントセッションのハンドルである必要があります。
ライセンス ID と証明書 ID は、DRMEnumerateLicense を使用して列挙できます。ライセンスストアから削除したいライセンスまたは証明書が既に手元にある場合は、それに対してクエリを実行して ID を取得し(DRMParseUnboundLicense 関数と DRMGetUnboundLicenseAttribute 関数を g_wszQUERY_IDVALUE 定数と共に使用します)、その値をこの関数に渡すことができます。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// msdrm.dll
#include <windows.h>
HRESULT DRMDeleteLicense(
DWORD hSession,
LPWSTR wszLicenseId
);[DllImport("msdrm.dll", ExactSpelling = true)]
static extern int DRMDeleteLicense(
uint hSession, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string wszLicenseId // LPWSTR
);<DllImport("msdrm.dll", ExactSpelling:=True)>
Public Shared Function DRMDeleteLicense(
hSession As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> wszLicenseId As String ' LPWSTR
) As Integer
End Function' hSession : DWORD
' wszLicenseId : LPWSTR
Declare PtrSafe Function DRMDeleteLicense Lib "msdrm" ( _
ByVal hSession As Long, _
ByVal wszLicenseId As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DRMDeleteLicense = ctypes.windll.msdrm.DRMDeleteLicense
DRMDeleteLicense.restype = ctypes.c_int
DRMDeleteLicense.argtypes = [
wintypes.DWORD, # hSession : DWORD
wintypes.LPCWSTR, # wszLicenseId : LPWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msdrm.dll')
DRMDeleteLicense = Fiddle::Function.new(
lib['DRMDeleteLicense'],
[
-Fiddle::TYPE_INT, # hSession : DWORD
Fiddle::TYPE_VOIDP, # wszLicenseId : LPWSTR
],
Fiddle::TYPE_INT)#[link(name = "msdrm")]
extern "system" {
fn DRMDeleteLicense(
hSession: u32, // DWORD
wszLicenseId: *mut u16 // LPWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msdrm.dll")]
public static extern int DRMDeleteLicense(uint hSession, [MarshalAs(UnmanagedType.LPWStr)] string wszLicenseId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msdrm_DRMDeleteLicense' -Namespace Win32 -PassThru
# $api::DRMDeleteLicense(hSession, wszLicenseId)#uselib "msdrm.dll"
#func global DRMDeleteLicense "DRMDeleteLicense" sptr, sptr
; DRMDeleteLicense hSession, wszLicenseId ; 戻り値は stat
; hSession : DWORD -> "sptr"
; wszLicenseId : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msdrm.dll"
#cfunc global DRMDeleteLicense "DRMDeleteLicense" int, wstr
; res = DRMDeleteLicense(hSession, wszLicenseId)
; hSession : DWORD -> "int"
; wszLicenseId : LPWSTR -> "wstr"; HRESULT DRMDeleteLicense(DWORD hSession, LPWSTR wszLicenseId)
#uselib "msdrm.dll"
#cfunc global DRMDeleteLicense "DRMDeleteLicense" int, wstr
; res = DRMDeleteLicense(hSession, wszLicenseId)
; hSession : DWORD -> "int"
; wszLicenseId : LPWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msdrm = windows.NewLazySystemDLL("msdrm.dll")
procDRMDeleteLicense = msdrm.NewProc("DRMDeleteLicense")
)
// hSession (DWORD), wszLicenseId (LPWSTR)
r1, _, err := procDRMDeleteLicense.Call(
uintptr(hSession),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszLicenseId))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DRMDeleteLicense(
hSession: DWORD; // DWORD
wszLicenseId: PWideChar // LPWSTR
): Integer; stdcall;
external 'msdrm.dll' name 'DRMDeleteLicense';result := DllCall("msdrm\DRMDeleteLicense"
, "UInt", hSession ; DWORD
, "WStr", wszLicenseId ; LPWSTR
, "Int") ; return: HRESULT●DRMDeleteLicense(hSession, wszLicenseId) = DLL("msdrm.dll", "int DRMDeleteLicense(dword, char*)")
# 呼び出し: DRMDeleteLicense(hSession, wszLicenseId)
# hSession : DWORD -> "dword"
# wszLicenseId : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msdrm" fn DRMDeleteLicense(
hSession: u32, // DWORD
wszLicenseId: [*c]const u16 // LPWSTR
) callconv(std.os.windows.WINAPI) i32;proc DRMDeleteLicense(
hSession: uint32, # DWORD
wszLicenseId: WideCString # LPWSTR
): int32 {.importc: "DRMDeleteLicense", stdcall, dynlib: "msdrm.dll".}pragma(lib, "msdrm");
extern(Windows)
int DRMDeleteLicense(
uint hSession, // DWORD
const(wchar)* wszLicenseId // LPWSTR
);ccall((:DRMDeleteLicense, "msdrm.dll"), stdcall, Int32,
(UInt32, Cwstring),
hSession, wszLicenseId)
# hSession : DWORD -> UInt32
# wszLicenseId : LPWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DRMDeleteLicense(
uint32_t hSession,
const uint16_t* wszLicenseId);
]]
local msdrm = ffi.load("msdrm")
-- msdrm.DRMDeleteLicense(hSession, wszLicenseId)
-- hSession : DWORD
-- wszLicenseId : LPWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msdrm.dll');
const DRMDeleteLicense = lib.func('__stdcall', 'DRMDeleteLicense', 'int32_t', ['uint32_t', 'str16']);
// DRMDeleteLicense(hSession, wszLicenseId)
// hSession : DWORD -> 'uint32_t'
// wszLicenseId : LPWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msdrm.dll", {
DRMDeleteLicense: { parameters: ["u32", "buffer"], result: "i32" },
});
// lib.symbols.DRMDeleteLicense(hSession, wszLicenseId)
// hSession : DWORD -> "u32"
// wszLicenseId : LPWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DRMDeleteLicense(
uint32_t hSession,
const uint16_t* wszLicenseId);
C, "msdrm.dll");
// $ffi->DRMDeleteLicense(hSession, wszLicenseId);
// hSession : DWORD
// wszLicenseId : LPWSTR
// 構造体/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 DRMDeleteLicense(
int hSession, // DWORD
WString wszLicenseId // LPWSTR
);
}@[Link("msdrm")]
lib Libmsdrm
fun DRMDeleteLicense = DRMDeleteLicense(
hSession : UInt32, # DWORD
wszLicenseId : UInt16* # LPWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DRMDeleteLicenseNative = Int32 Function(Uint32, Pointer<Utf16>);
typedef DRMDeleteLicenseDart = int Function(int, Pointer<Utf16>);
final DRMDeleteLicense = DynamicLibrary.open('msdrm.dll')
.lookupFunction<DRMDeleteLicenseNative, DRMDeleteLicenseDart>('DRMDeleteLicense');
// hSession : DWORD -> Uint32
// wszLicenseId : LPWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DRMDeleteLicense(
hSession: DWORD; // DWORD
wszLicenseId: PWideChar // LPWSTR
): Integer; stdcall;
external 'msdrm.dll' name 'DRMDeleteLicense';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DRMDeleteLicense"
c_DRMDeleteLicense :: Word32 -> CWString -> IO Int32
-- hSession : DWORD -> Word32
-- wszLicenseId : LPWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drmdeletelicense =
foreign "DRMDeleteLicense"
(uint32_t @-> (ptr uint16_t) @-> returning int32_t)
(* hSession : DWORD -> uint32_t *)
(* wszLicenseId : LPWSTR -> (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 ("DRMDeleteLicense" drmdelete-license :convention :stdcall) :int32
(h-session :uint32) ; DWORD
(wsz-license-id (:string :encoding :utf-16le))) ; LPWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DRMDeleteLicense = Win32::API::More->new('msdrm',
'int DRMDeleteLicense(DWORD hSession, LPCWSTR wszLicenseId)');
# my $ret = $DRMDeleteLicense->Call($hSession, $wszLicenseId);
# hSession : DWORD -> DWORD
# wszLicenseId : LPWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f DRMEnumerateLicense — 保存されているライセンスを列挙する。
- f DRMGetUnboundLicenseAttribute — 未バインドライセンスから指定の属性値を取得する。
- f DRMParseUnboundLicense — 未バインドのライセンスを解析しクエリハンドルを得る。