CheckGamingPrivilegeSilently
関数UIなしでゲーム権限の有無を確認する。
シグネチャ
// api-ms-win-gaming-tcui-l1-1-1.dll
#include <windows.h>
HRESULT CheckGamingPrivilegeSilently(
DWORD privilegeId,
HSTRING scope,
HSTRING policy,
BOOL* hasPrivilege
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| privilegeId | DWORD | in | 確認する特権のID。 |
| scope | HSTRING | in | 特権チェックのスコープを表すHSTRING。NULL可。 |
| policy | HSTRING | in | 適用するポリシーを表すHSTRING。NULL可。 |
| hasPrivilege | BOOL* | out | 特権を保持しているかを受け取るBOOL出力先。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// api-ms-win-gaming-tcui-l1-1-1.dll
#include <windows.h>
HRESULT CheckGamingPrivilegeSilently(
DWORD privilegeId,
HSTRING scope,
HSTRING policy,
BOOL* hasPrivilege
);[DllImport("api-ms-win-gaming-tcui-l1-1-1.dll", ExactSpelling = true)]
static extern int CheckGamingPrivilegeSilently(
uint privilegeId, // DWORD
IntPtr scope, // HSTRING
IntPtr policy, // HSTRING
out bool hasPrivilege // BOOL* out
);<DllImport("api-ms-win-gaming-tcui-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function CheckGamingPrivilegeSilently(
privilegeId As UInteger, ' DWORD
scope As IntPtr, ' HSTRING
policy As IntPtr, ' HSTRING
<Out> ByRef hasPrivilege As Boolean ' BOOL* out
) As Integer
End Function' privilegeId : DWORD
' scope : HSTRING
' policy : HSTRING
' hasPrivilege : BOOL* out
Declare PtrSafe Function CheckGamingPrivilegeSilently Lib "api-ms-win-gaming-tcui-l1-1-1" ( _
ByVal privilegeId As Long, _
ByVal scope As LongPtr, _
ByVal policy As LongPtr, _
ByRef hasPrivilege As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CheckGamingPrivilegeSilently = ctypes.windll.LoadLibrary("api-ms-win-gaming-tcui-l1-1-1.dll").CheckGamingPrivilegeSilently
CheckGamingPrivilegeSilently.restype = ctypes.c_int
CheckGamingPrivilegeSilently.argtypes = [
wintypes.DWORD, # privilegeId : DWORD
wintypes.HANDLE, # scope : HSTRING
wintypes.HANDLE, # policy : HSTRING
ctypes.c_void_p, # hasPrivilege : BOOL* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-gaming-tcui-l1-1-1.dll')
CheckGamingPrivilegeSilently = Fiddle::Function.new(
lib['CheckGamingPrivilegeSilently'],
[
-Fiddle::TYPE_INT, # privilegeId : DWORD
Fiddle::TYPE_VOIDP, # scope : HSTRING
Fiddle::TYPE_VOIDP, # policy : HSTRING
Fiddle::TYPE_VOIDP, # hasPrivilege : BOOL* out
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-gaming-tcui-l1-1-1")]
extern "system" {
fn CheckGamingPrivilegeSilently(
privilegeId: u32, // DWORD
scope: *mut core::ffi::c_void, // HSTRING
policy: *mut core::ffi::c_void, // HSTRING
hasPrivilege: *mut i32 // BOOL* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-gaming-tcui-l1-1-1.dll")]
public static extern int CheckGamingPrivilegeSilently(uint privilegeId, IntPtr scope, IntPtr policy, out bool hasPrivilege);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-gaming-tcui-l1-1-1_CheckGamingPrivilegeSilently' -Namespace Win32 -PassThru
# $api::CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege)#uselib "api-ms-win-gaming-tcui-l1-1-1.dll"
#func global CheckGamingPrivilegeSilently "CheckGamingPrivilegeSilently" sptr, sptr, sptr, sptr
; CheckGamingPrivilegeSilently privilegeId, scope, policy, varptr(hasPrivilege) ; 戻り値は stat
; privilegeId : DWORD -> "sptr"
; scope : HSTRING -> "sptr"
; policy : HSTRING -> "sptr"
; hasPrivilege : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-gaming-tcui-l1-1-1.dll" #cfunc global CheckGamingPrivilegeSilently "CheckGamingPrivilegeSilently" int, sptr, sptr, var ; res = CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege) ; privilegeId : DWORD -> "int" ; scope : HSTRING -> "sptr" ; policy : HSTRING -> "sptr" ; hasPrivilege : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-gaming-tcui-l1-1-1.dll" #cfunc global CheckGamingPrivilegeSilently "CheckGamingPrivilegeSilently" int, sptr, sptr, sptr ; res = CheckGamingPrivilegeSilently(privilegeId, scope, policy, varptr(hasPrivilege)) ; privilegeId : DWORD -> "int" ; scope : HSTRING -> "sptr" ; policy : HSTRING -> "sptr" ; hasPrivilege : BOOL* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT CheckGamingPrivilegeSilently(DWORD privilegeId, HSTRING scope, HSTRING policy, BOOL* hasPrivilege) #uselib "api-ms-win-gaming-tcui-l1-1-1.dll" #cfunc global CheckGamingPrivilegeSilently "CheckGamingPrivilegeSilently" int, intptr, intptr, var ; res = CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege) ; privilegeId : DWORD -> "int" ; scope : HSTRING -> "intptr" ; policy : HSTRING -> "intptr" ; hasPrivilege : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT CheckGamingPrivilegeSilently(DWORD privilegeId, HSTRING scope, HSTRING policy, BOOL* hasPrivilege) #uselib "api-ms-win-gaming-tcui-l1-1-1.dll" #cfunc global CheckGamingPrivilegeSilently "CheckGamingPrivilegeSilently" int, intptr, intptr, intptr ; res = CheckGamingPrivilegeSilently(privilegeId, scope, policy, varptr(hasPrivilege)) ; privilegeId : DWORD -> "int" ; scope : HSTRING -> "intptr" ; policy : HSTRING -> "intptr" ; hasPrivilege : BOOL* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_gaming_tcui_l1_1_1 = windows.NewLazySystemDLL("api-ms-win-gaming-tcui-l1-1-1.dll")
procCheckGamingPrivilegeSilently = api_ms_win_gaming_tcui_l1_1_1.NewProc("CheckGamingPrivilegeSilently")
)
// privilegeId (DWORD), scope (HSTRING), policy (HSTRING), hasPrivilege (BOOL* out)
r1, _, err := procCheckGamingPrivilegeSilently.Call(
uintptr(privilegeId),
uintptr(scope),
uintptr(policy),
uintptr(hasPrivilege),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CheckGamingPrivilegeSilently(
privilegeId: DWORD; // DWORD
scope: THandle; // HSTRING
policy: THandle; // HSTRING
hasPrivilege: Pointer // BOOL* out
): Integer; stdcall;
external 'api-ms-win-gaming-tcui-l1-1-1.dll' name 'CheckGamingPrivilegeSilently';result := DllCall("api-ms-win-gaming-tcui-l1-1-1\CheckGamingPrivilegeSilently"
, "UInt", privilegeId ; DWORD
, "Ptr", scope ; HSTRING
, "Ptr", policy ; HSTRING
, "Ptr", hasPrivilege ; BOOL* out
, "Int") ; return: HRESULT●CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege) = DLL("api-ms-win-gaming-tcui-l1-1-1.dll", "int CheckGamingPrivilegeSilently(dword, void*, void*, void*)")
# 呼び出し: CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege)
# privilegeId : DWORD -> "dword"
# scope : HSTRING -> "void*"
# policy : HSTRING -> "void*"
# hasPrivilege : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-gaming-tcui-l1-1-1" fn CheckGamingPrivilegeSilently(
privilegeId: u32, // DWORD
scope: ?*anyopaque, // HSTRING
policy: ?*anyopaque, // HSTRING
hasPrivilege: [*c]i32 // BOOL* out
) callconv(std.os.windows.WINAPI) i32;proc CheckGamingPrivilegeSilently(
privilegeId: uint32, # DWORD
scope: pointer, # HSTRING
policy: pointer, # HSTRING
hasPrivilege: ptr int32 # BOOL* out
): int32 {.importc: "CheckGamingPrivilegeSilently", stdcall, dynlib: "api-ms-win-gaming-tcui-l1-1-1.dll".}pragma(lib, "api-ms-win-gaming-tcui-l1-1-1");
extern(Windows)
int CheckGamingPrivilegeSilently(
uint privilegeId, // DWORD
void* scope, // HSTRING
void* policy, // HSTRING
int* hasPrivilege // BOOL* out
);ccall((:CheckGamingPrivilegeSilently, "api-ms-win-gaming-tcui-l1-1-1.dll"), stdcall, Int32,
(UInt32, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Int32}),
privilegeId, scope, policy, hasPrivilege)
# privilegeId : DWORD -> UInt32
# scope : HSTRING -> Ptr{Cvoid}
# policy : HSTRING -> Ptr{Cvoid}
# hasPrivilege : BOOL* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CheckGamingPrivilegeSilently(
uint32_t privilegeId,
void* scope,
void* policy,
int32_t* hasPrivilege);
]]
local api-ms-win-gaming-tcui-l1-1-1 = ffi.load("api-ms-win-gaming-tcui-l1-1-1")
-- api-ms-win-gaming-tcui-l1-1-1.CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege)
-- privilegeId : DWORD
-- scope : HSTRING
-- policy : HSTRING
-- hasPrivilege : BOOL* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-gaming-tcui-l1-1-1.dll');
const CheckGamingPrivilegeSilently = lib.func('__stdcall', 'CheckGamingPrivilegeSilently', 'int32_t', ['uint32_t', 'void *', 'void *', 'int32_t *']);
// CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege)
// privilegeId : DWORD -> 'uint32_t'
// scope : HSTRING -> 'void *'
// policy : HSTRING -> 'void *'
// hasPrivilege : BOOL* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-gaming-tcui-l1-1-1.dll", {
CheckGamingPrivilegeSilently: { parameters: ["u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege)
// privilegeId : DWORD -> "u32"
// scope : HSTRING -> "pointer"
// policy : HSTRING -> "pointer"
// hasPrivilege : BOOL* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CheckGamingPrivilegeSilently(
uint32_t privilegeId,
void* scope,
void* policy,
int32_t* hasPrivilege);
C, "api-ms-win-gaming-tcui-l1-1-1.dll");
// $ffi->CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege);
// privilegeId : DWORD
// scope : HSTRING
// policy : HSTRING
// hasPrivilege : BOOL* 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 Api-ms-win-gaming-tcui-l1-1-1 extends StdCallLibrary {
Api-ms-win-gaming-tcui-l1-1-1 INSTANCE = Native.load("api-ms-win-gaming-tcui-l1-1-1", Api-ms-win-gaming-tcui-l1-1-1.class);
int CheckGamingPrivilegeSilently(
int privilegeId, // DWORD
Pointer scope, // HSTRING
Pointer policy, // HSTRING
IntByReference hasPrivilege // BOOL* out
);
}@[Link("api-ms-win-gaming-tcui-l1-1-1")]
lib Libapi-ms-win-gaming-tcui-l1-1-1
fun CheckGamingPrivilegeSilently = CheckGamingPrivilegeSilently(
privilegeId : UInt32, # DWORD
scope : Void*, # HSTRING
policy : Void*, # HSTRING
hasPrivilege : Int32* # BOOL* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CheckGamingPrivilegeSilentlyNative = Int32 Function(Uint32, Pointer<Void>, Pointer<Void>, Pointer<Int32>);
typedef CheckGamingPrivilegeSilentlyDart = int Function(int, Pointer<Void>, Pointer<Void>, Pointer<Int32>);
final CheckGamingPrivilegeSilently = DynamicLibrary.open('api-ms-win-gaming-tcui-l1-1-1.dll')
.lookupFunction<CheckGamingPrivilegeSilentlyNative, CheckGamingPrivilegeSilentlyDart>('CheckGamingPrivilegeSilently');
// privilegeId : DWORD -> Uint32
// scope : HSTRING -> Pointer<Void>
// policy : HSTRING -> Pointer<Void>
// hasPrivilege : BOOL* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CheckGamingPrivilegeSilently(
privilegeId: DWORD; // DWORD
scope: THandle; // HSTRING
policy: THandle; // HSTRING
hasPrivilege: Pointer // BOOL* out
): Integer; stdcall;
external 'api-ms-win-gaming-tcui-l1-1-1.dll' name 'CheckGamingPrivilegeSilently';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CheckGamingPrivilegeSilently"
c_CheckGamingPrivilegeSilently :: Word32 -> Ptr () -> Ptr () -> Ptr CInt -> IO Int32
-- privilegeId : DWORD -> Word32
-- scope : HSTRING -> Ptr ()
-- policy : HSTRING -> Ptr ()
-- hasPrivilege : BOOL* out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let checkgamingprivilegesilently =
foreign "CheckGamingPrivilegeSilently"
(uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* privilegeId : DWORD -> uint32_t *)
(* scope : HSTRING -> (ptr void) *)
(* policy : HSTRING -> (ptr void) *)
(* hasPrivilege : BOOL* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-gaming-tcui-l1-1-1 (t "api-ms-win-gaming-tcui-l1-1-1.dll"))
(cffi:use-foreign-library api-ms-win-gaming-tcui-l1-1-1)
(cffi:defcfun ("CheckGamingPrivilegeSilently" check-gaming-privilege-silently :convention :stdcall) :int32
(privilege-id :uint32) ; DWORD
(scope :pointer) ; HSTRING
(policy :pointer) ; HSTRING
(has-privilege :pointer)) ; BOOL* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CheckGamingPrivilegeSilently = Win32::API::More->new('api-ms-win-gaming-tcui-l1-1-1',
'int CheckGamingPrivilegeSilently(DWORD privilegeId, HANDLE scope, HANDLE policy, LPVOID hasPrivilege)');
# my $ret = $CheckGamingPrivilegeSilently->Call($privilegeId, $scope, $policy, $hasPrivilege);
# privilegeId : DWORD -> DWORD
# scope : HSTRING -> HANDLE
# policy : HSTRING -> HANDLE
# hasPrivilege : BOOL* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。