Win32 API 日本語リファレンス
ホームWeb.InternetExplorer › IERegisterWritableRegistryKey

IERegisterWritableRegistryKey

関数
書き込み可能なレジストリキーを登録する。
DLLIeframe.dll呼出規約winapi

シグネチャ

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

HRESULT IERegisterWritableRegistryKey(
    GUID guid,
    LPCWSTR lpSubkey,
    BOOL fSubkeyAllowed
);

パラメーター

名前方向説明
guidGUIDin保護モードのプロセスが書き込みを許可されるレジストリ領域を識別するGUIDを指定する。
lpSubkeyLPCWSTRin書き込み可能として登録する対象のサブキーパスを指す文字列を指定する。NULL可。
fSubkeyAllowedBOOLin配下のサブキー作成も許可するかを指定するブール値。TRUEで許可、FALSEで禁止。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT IERegisterWritableRegistryKey(
    GUID guid,
    LPCWSTR lpSubkey,
    BOOL fSubkeyAllowed
);
[DllImport("Ieframe.dll", ExactSpelling = true)]
static extern int IERegisterWritableRegistryKey(
    Guid guid,   // GUID
    [MarshalAs(UnmanagedType.LPWStr)] string lpSubkey,   // LPCWSTR
    bool fSubkeyAllowed   // BOOL
);
<DllImport("Ieframe.dll", ExactSpelling:=True)>
Public Shared Function IERegisterWritableRegistryKey(
    guid As Guid,   ' GUID
    <MarshalAs(UnmanagedType.LPWStr)> lpSubkey As String,   ' LPCWSTR
    fSubkeyAllowed As Boolean   ' BOOL
) As Integer
End Function
' guid : GUID
' lpSubkey : LPCWSTR
' fSubkeyAllowed : BOOL
Declare PtrSafe Function IERegisterWritableRegistryKey Lib "ieframe" ( _
    ByVal guid As LongPtr, _
    ByVal lpSubkey As LongPtr, _
    ByVal fSubkeyAllowed As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IERegisterWritableRegistryKey = ctypes.windll.ieframe.IERegisterWritableRegistryKey
IERegisterWritableRegistryKey.restype = ctypes.c_int
IERegisterWritableRegistryKey.argtypes = [
    ctypes.c_void_p,  # guid : GUID
    wintypes.LPCWSTR,  # lpSubkey : LPCWSTR
    wintypes.BOOL,  # fSubkeyAllowed : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('Ieframe.dll')
IERegisterWritableRegistryKey = Fiddle::Function.new(
  lib['IERegisterWritableRegistryKey'],
  [
    Fiddle::TYPE_VOIDP,  # guid : GUID
    Fiddle::TYPE_VOIDP,  # lpSubkey : LPCWSTR
    Fiddle::TYPE_INT,  # fSubkeyAllowed : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "ieframe")]
extern "system" {
    fn IERegisterWritableRegistryKey(
        guid: GUID,  // GUID
        lpSubkey: *const u16,  // LPCWSTR
        fSubkeyAllowed: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("Ieframe.dll")]
public static extern int IERegisterWritableRegistryKey(Guid guid, [MarshalAs(UnmanagedType.LPWStr)] string lpSubkey, bool fSubkeyAllowed);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Ieframe_IERegisterWritableRegistryKey' -Namespace Win32 -PassThru
# $api::IERegisterWritableRegistryKey(guid, lpSubkey, fSubkeyAllowed)
#uselib "Ieframe.dll"
#func global IERegisterWritableRegistryKey "IERegisterWritableRegistryKey" sptr, sptr, sptr
; IERegisterWritableRegistryKey guid, lpSubkey, fSubkeyAllowed   ; 戻り値は stat
; guid : GUID -> "sptr"
; lpSubkey : LPCWSTR -> "sptr"
; fSubkeyAllowed : BOOL -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "Ieframe.dll"
#cfunc global IERegisterWritableRegistryKey "IERegisterWritableRegistryKey" int, wstr, int
; res = IERegisterWritableRegistryKey(guid, lpSubkey, fSubkeyAllowed)
; guid : GUID -> "int"
; lpSubkey : LPCWSTR -> "wstr"
; fSubkeyAllowed : BOOL -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; HRESULT IERegisterWritableRegistryKey(GUID guid, LPCWSTR lpSubkey, BOOL fSubkeyAllowed)
#uselib "Ieframe.dll"
#cfunc global IERegisterWritableRegistryKey "IERegisterWritableRegistryKey" int, wstr, int
; res = IERegisterWritableRegistryKey(guid, lpSubkey, fSubkeyAllowed)
; guid : GUID -> "int"
; lpSubkey : LPCWSTR -> "wstr"
; fSubkeyAllowed : BOOL -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ieframe = windows.NewLazySystemDLL("Ieframe.dll")
	procIERegisterWritableRegistryKey = ieframe.NewProc("IERegisterWritableRegistryKey")
)

// guid (GUID), lpSubkey (LPCWSTR), fSubkeyAllowed (BOOL)
r1, _, err := procIERegisterWritableRegistryKey.Call(
	uintptr(guid),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpSubkey))),
	uintptr(fSubkeyAllowed),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function IERegisterWritableRegistryKey(
  guid: TGUID;   // GUID
  lpSubkey: PWideChar;   // LPCWSTR
  fSubkeyAllowed: BOOL   // BOOL
): Integer; stdcall;
  external 'Ieframe.dll' name 'IERegisterWritableRegistryKey';
result := DllCall("Ieframe\IERegisterWritableRegistryKey"
    , "Ptr", guid   ; GUID
    , "WStr", lpSubkey   ; LPCWSTR
    , "Int", fSubkeyAllowed   ; BOOL
    , "Int")   ; return: HRESULT
●IERegisterWritableRegistryKey(guid, lpSubkey, fSubkeyAllowed) = DLL("Ieframe.dll", "int IERegisterWritableRegistryKey(void*, char*, bool)")
# 呼び出し: IERegisterWritableRegistryKey(guid, lpSubkey, fSubkeyAllowed)
# guid : GUID -> "void*"
# lpSubkey : LPCWSTR -> "char*"
# fSubkeyAllowed : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef IERegisterWritableRegistryKeyNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Int32);
typedef IERegisterWritableRegistryKeyDart = int Function(Pointer<Void>, Pointer<Utf16>, int);
final IERegisterWritableRegistryKey = DynamicLibrary.open('Ieframe.dll')
    .lookupFunction<IERegisterWritableRegistryKeyNative, IERegisterWritableRegistryKeyDart>('IERegisterWritableRegistryKey');
// guid : GUID -> Pointer<Void>
// lpSubkey : LPCWSTR -> Pointer<Utf16>
// fSubkeyAllowed : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function IERegisterWritableRegistryKey(
  guid: TGUID;   // GUID
  lpSubkey: PWideChar;   // LPCWSTR
  fSubkeyAllowed: BOOL   // BOOL
): Integer; stdcall;
  external 'Ieframe.dll' name 'IERegisterWritableRegistryKey';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "IERegisterWritableRegistryKey"
  c_IERegisterWritableRegistryKey :: Ptr () -> CWString -> CInt -> IO Int32
-- guid : GUID -> Ptr ()
-- lpSubkey : LPCWSTR -> CWString
-- fSubkeyAllowed : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。
open Ctypes
open Foreign

let ieregisterwritableregistrykey =
  foreign "IERegisterWritableRegistryKey"
    ((ptr void) @-> (ptr uint16_t) @-> int32_t @-> returning int32_t)
(* guid : GUID -> (ptr void) *)
(* lpSubkey : LPCWSTR -> (ptr uint16_t) *)
(* fSubkeyAllowed : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library ieframe (t "Ieframe.dll"))
(cffi:use-foreign-library ieframe)

(cffi:defcfun ("IERegisterWritableRegistryKey" ieregister-writable-registry-key :convention :stdcall) :int32
  (guid :pointer)   ; GUID
  (lp-subkey (:string :encoding :utf-16le))   ; LPCWSTR
  (f-subkey-allowed :int32))   ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $IERegisterWritableRegistryKey = Win32::API::More->new('Ieframe',
    'int IERegisterWritableRegistryKey(LPVOID guid, LPCWSTR lpSubkey, BOOL fSubkeyAllowed)');
# my $ret = $IERegisterWritableRegistryKey->Call($guid, $lpSubkey, $fSubkeyAllowed);
# guid : GUID -> LPVOID
# lpSubkey : LPCWSTR -> LPCWSTR
# fSubkeyAllowed : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。