Win32 API 日本語リファレンス
ホームGaming › CheckGamingPrivilegeSilently

CheckGamingPrivilegeSilently

関数
UIなしでゲーム権限の有無を確認する。
DLLapi-ms-win-gaming-tcui-l1-1-1.dll呼出規約winapi

シグネチャ

// api-ms-win-gaming-tcui-l1-1-1.dll
#include <windows.h>

HRESULT CheckGamingPrivilegeSilently(
    DWORD privilegeId,
    HSTRING scope,
    HSTRING policy,
    BOOL* hasPrivilege
);

パラメーター

名前方向
privilegeIdDWORDin
scopeHSTRINGin
policyHSTRINGin
hasPrivilegeBOOL*out

戻り値の型: 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 int 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 Integer   ' 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 int 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, 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, int
; res = CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege)
; privilegeId : DWORD -> "int"
; scope : HSTRING -> "sptr"
; policy : HSTRING -> "sptr"
; hasPrivilege : BOOL* out -> "int"
; 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, int
; res = CheckGamingPrivilegeSilently(privilegeId, scope, policy, hasPrivilege)
; privilegeId : DWORD -> "int"
; scope : HSTRING -> "intptr"
; policy : HSTRING -> "intptr"
; hasPrivilege : BOOL* out -> "int"
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   // HRESULT
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';
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)。