ホーム › System.ApplicationInstallationAndServicing › SfcIsKeyProtected
SfcIsKeyProtected
関数指定したレジストリキーが保護対象かを判定する。
シグネチャ
// sfc.dll
#include <windows.h>
BOOL SfcIsKeyProtected(
HKEY KeyHandle,
LPCWSTR SubKeyName,
DWORD KeySam
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| KeyHandle | HKEY | in |
| SubKeyName | LPCWSTR | in |
| KeySam | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// sfc.dll
#include <windows.h>
BOOL SfcIsKeyProtected(
HKEY KeyHandle,
LPCWSTR SubKeyName,
DWORD KeySam
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("sfc.dll", ExactSpelling = true)]
static extern bool SfcIsKeyProtected(
IntPtr KeyHandle, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string SubKeyName, // LPCWSTR
uint KeySam // DWORD
);<DllImport("sfc.dll", ExactSpelling:=True)>
Public Shared Function SfcIsKeyProtected(
KeyHandle As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> SubKeyName As String, ' LPCWSTR
KeySam As UInteger ' DWORD
) As Boolean
End Function' KeyHandle : HKEY
' SubKeyName : LPCWSTR
' KeySam : DWORD
Declare PtrSafe Function SfcIsKeyProtected Lib "sfc" ( _
ByVal KeyHandle As LongPtr, _
ByVal SubKeyName As LongPtr, _
ByVal KeySam As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SfcIsKeyProtected = ctypes.windll.sfc.SfcIsKeyProtected
SfcIsKeyProtected.restype = wintypes.BOOL
SfcIsKeyProtected.argtypes = [
wintypes.HANDLE, # KeyHandle : HKEY
wintypes.LPCWSTR, # SubKeyName : LPCWSTR
wintypes.DWORD, # KeySam : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('sfc.dll')
SfcIsKeyProtected = Fiddle::Function.new(
lib['SfcIsKeyProtected'],
[
Fiddle::TYPE_VOIDP, # KeyHandle : HKEY
Fiddle::TYPE_VOIDP, # SubKeyName : LPCWSTR
-Fiddle::TYPE_INT, # KeySam : DWORD
],
Fiddle::TYPE_INT)#[link(name = "sfc")]
extern "system" {
fn SfcIsKeyProtected(
KeyHandle: *mut core::ffi::c_void, // HKEY
SubKeyName: *const u16, // LPCWSTR
KeySam: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("sfc.dll")]
public static extern bool SfcIsKeyProtected(IntPtr KeyHandle, [MarshalAs(UnmanagedType.LPWStr)] string SubKeyName, uint KeySam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'sfc_SfcIsKeyProtected' -Namespace Win32 -PassThru
# $api::SfcIsKeyProtected(KeyHandle, SubKeyName, KeySam)#uselib "sfc.dll"
#func global SfcIsKeyProtected "SfcIsKeyProtected" sptr, sptr, sptr
; SfcIsKeyProtected KeyHandle, SubKeyName, KeySam ; 戻り値は stat
; KeyHandle : HKEY -> "sptr"
; SubKeyName : LPCWSTR -> "sptr"
; KeySam : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "sfc.dll"
#cfunc global SfcIsKeyProtected "SfcIsKeyProtected" sptr, wstr, int
; res = SfcIsKeyProtected(KeyHandle, SubKeyName, KeySam)
; KeyHandle : HKEY -> "sptr"
; SubKeyName : LPCWSTR -> "wstr"
; KeySam : DWORD -> "int"; BOOL SfcIsKeyProtected(HKEY KeyHandle, LPCWSTR SubKeyName, DWORD KeySam)
#uselib "sfc.dll"
#cfunc global SfcIsKeyProtected "SfcIsKeyProtected" intptr, wstr, int
; res = SfcIsKeyProtected(KeyHandle, SubKeyName, KeySam)
; KeyHandle : HKEY -> "intptr"
; SubKeyName : LPCWSTR -> "wstr"
; KeySam : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
sfc = windows.NewLazySystemDLL("sfc.dll")
procSfcIsKeyProtected = sfc.NewProc("SfcIsKeyProtected")
)
// KeyHandle (HKEY), SubKeyName (LPCWSTR), KeySam (DWORD)
r1, _, err := procSfcIsKeyProtected.Call(
uintptr(KeyHandle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SubKeyName))),
uintptr(KeySam),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SfcIsKeyProtected(
KeyHandle: THandle; // HKEY
SubKeyName: PWideChar; // LPCWSTR
KeySam: DWORD // DWORD
): BOOL; stdcall;
external 'sfc.dll' name 'SfcIsKeyProtected';result := DllCall("sfc\SfcIsKeyProtected"
, "Ptr", KeyHandle ; HKEY
, "WStr", SubKeyName ; LPCWSTR
, "UInt", KeySam ; DWORD
, "Int") ; return: BOOL●SfcIsKeyProtected(KeyHandle, SubKeyName, KeySam) = DLL("sfc.dll", "bool SfcIsKeyProtected(void*, char*, dword)")
# 呼び出し: SfcIsKeyProtected(KeyHandle, SubKeyName, KeySam)
# KeyHandle : HKEY -> "void*"
# SubKeyName : LPCWSTR -> "char*"
# KeySam : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。