Win32 API 日本語リファレンス
ホームSystem.Registry › RegDisablePredefinedCacheEx

RegDisablePredefinedCacheEx

関数
プロセス全体のHKCU定義済みキーキャッシュを無効化する。
DLLADVAPI32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// ADVAPI32.dll
#include <windows.h>

WIN32_ERROR RegDisablePredefinedCacheEx(void);

パラメーターなし。戻り値: WIN32_ERROR

公式ドキュメント

現在のプロセスにおける、すべての定義済みレジストリ ハンドルのハンドル キャッシュを無効化します。

戻り値

関数が成功した場合、戻り値は ERROR_SUCCESS です。

関数が失敗した場合、戻り値は システム エラー コード です。

解説(Remarks)

この関数はリモート コンピューターでは動作しません。

偽装 (impersonation) を変更するサービスは、定義済みハンドルを使用する前にこの関数を呼び出す必要があります。

たとえば、この関数を呼び出した後に HKEY_CURRENT_USER へアクセスすると、HKEY_USERS\SID_of_current_user に対して、または現在のユーザーのハイブが読み込まれていない場合は HKEY_USERS.DEFAULT に対して、オープンおよびクローズ操作が実行されます。SID の詳細については、 Security Identifiers を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// ADVAPI32.dll
#include <windows.h>

WIN32_ERROR RegDisablePredefinedCacheEx(void);
[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern uint RegDisablePredefinedCacheEx();
<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function RegDisablePredefinedCacheEx() As UInteger
End Function
Declare PtrSafe Function RegDisablePredefinedCacheEx Lib "advapi32" () As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RegDisablePredefinedCacheEx = ctypes.windll.advapi32.RegDisablePredefinedCacheEx
RegDisablePredefinedCacheEx.restype = wintypes.DWORD
RegDisablePredefinedCacheEx.argtypes = []
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
RegDisablePredefinedCacheEx = Fiddle::Function.new(
  lib['RegDisablePredefinedCacheEx'],
  [],
  -Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn RegDisablePredefinedCacheEx() -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVAPI32.dll")]
public static extern uint RegDisablePredefinedCacheEx();
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_RegDisablePredefinedCacheEx' -Namespace Win32 -PassThru
# $api::RegDisablePredefinedCacheEx()
#uselib "ADVAPI32.dll"
#func global RegDisablePredefinedCacheEx "RegDisablePredefinedCacheEx"
; RegDisablePredefinedCacheEx   ; 戻り値は stat
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVAPI32.dll"
#cfunc global RegDisablePredefinedCacheEx "RegDisablePredefinedCacheEx"
; res = RegDisablePredefinedCacheEx()
; WIN32_ERROR RegDisablePredefinedCacheEx()
#uselib "ADVAPI32.dll"
#cfunc global RegDisablePredefinedCacheEx "RegDisablePredefinedCacheEx"
; res = RegDisablePredefinedCacheEx()
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procRegDisablePredefinedCacheEx = advapi32.NewProc("RegDisablePredefinedCacheEx")
)

r1, _, err := procRegDisablePredefinedCacheEx.Call()
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function RegDisablePredefinedCacheEx: DWORD; stdcall;
  external 'ADVAPI32.dll' name 'RegDisablePredefinedCacheEx';
result := DllCall("ADVAPI32\RegDisablePredefinedCacheEx", "UInt")
●RegDisablePredefinedCacheEx() = DLL("ADVAPI32.dll", "dword RegDisablePredefinedCacheEx()")
# 呼び出し: RegDisablePredefinedCacheEx()
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "advapi32" fn RegDisablePredefinedCacheEx() callconv(std.os.windows.WINAPI) u32;
proc RegDisablePredefinedCacheEx(): uint32 {.importc: "RegDisablePredefinedCacheEx", stdcall, dynlib: "ADVAPI32.dll".}
pragma(lib, "advapi32");
extern(Windows)
uint RegDisablePredefinedCacheEx();
ccall((:RegDisablePredefinedCacheEx, "ADVAPI32.dll"), stdcall, UInt32,
      (),
      )
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t RegDisablePredefinedCacheEx(void);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.RegDisablePredefinedCacheEx()
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const RegDisablePredefinedCacheEx = lib.func('__stdcall', 'RegDisablePredefinedCacheEx', 'uint32_t', []);
// RegDisablePredefinedCacheEx()
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ADVAPI32.dll", {
  RegDisablePredefinedCacheEx: { parameters: [], result: "u32" },
});
// lib.symbols.RegDisablePredefinedCacheEx()
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t RegDisablePredefinedCacheEx(void);
C, "ADVAPI32.dll");
// $ffi->RegDisablePredefinedCacheEx();
// 構造体/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 Advapi32 extends StdCallLibrary {
    Advapi32 INSTANCE = Native.load("advapi32", Advapi32.class);
    int RegDisablePredefinedCacheEx();
}
@[Link("advapi32")]
lib LibADVAPI32
  fun RegDisablePredefinedCacheEx = RegDisablePredefinedCacheEx() : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RegDisablePredefinedCacheExNative = Uint32 Function();
typedef RegDisablePredefinedCacheExDart = int Function();
final RegDisablePredefinedCacheEx = DynamicLibrary.open('ADVAPI32.dll')
    .lookupFunction<RegDisablePredefinedCacheExNative, RegDisablePredefinedCacheExDart>('RegDisablePredefinedCacheEx');
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RegDisablePredefinedCacheEx: DWORD; stdcall;
  external 'ADVAPI32.dll' name 'RegDisablePredefinedCacheEx';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RegDisablePredefinedCacheEx"
  c_RegDisablePredefinedCacheEx :: IO Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let regdisablepredefinedcacheex =
  foreign "RegDisablePredefinedCacheEx"
    (void @-> returning uint32_t)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)

(cffi:defcfun ("RegDisablePredefinedCacheEx" reg-disable-predefined-cache-ex :convention :stdcall) :uint32)
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RegDisablePredefinedCacheEx = Win32::API::More->new('ADVAPI32',
    'DWORD RegDisablePredefinedCacheEx()');
# my $ret = $RegDisablePredefinedCacheEx->Call();
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API
使用する型