ホーム › Web.InternetExplorer › IERegSetValueEx
IERegSetValueEx
関数IE保護モードでレジストリ値を設定する。
シグネチャ
// Ieframe.dll
#include <windows.h>
HRESULT IERegSetValueEx(
LPCWSTR lpSubKey,
LPCWSTR lpValueName,
DWORD Reserved,
DWORD dwType,
const BYTE* lpData,
DWORD cbData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpSubKey | LPCWSTR | in | 値を設定する対象のサブキーパスを指す文字列を指定する。 |
| lpValueName | LPCWSTR | in | 設定する値の名前を指す文字列を指定する。既定値はNULLまたは空文字。 |
| Reserved | DWORD | in | 予約済みパラメータ。0を指定する必要がある。 |
| dwType | DWORD | in | 設定する値のデータ型を指定する。REG_SZやREG_BINARY等のレジストリ型定数。 |
| lpData | BYTE* | in | 設定する値のデータを格納したバッファへのポインタを指定する。 |
| cbData | DWORD | in | lpDataのデータサイズをバイト単位で指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// Ieframe.dll
#include <windows.h>
HRESULT IERegSetValueEx(
LPCWSTR lpSubKey,
LPCWSTR lpValueName,
DWORD Reserved,
DWORD dwType,
const BYTE* lpData,
DWORD cbData
);[DllImport("Ieframe.dll", ExactSpelling = true)]
static extern int IERegSetValueEx(
[MarshalAs(UnmanagedType.LPWStr)] string lpSubKey, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpValueName, // LPCWSTR
uint Reserved, // DWORD
uint dwType, // DWORD
IntPtr lpData, // BYTE*
uint cbData // DWORD
);<DllImport("Ieframe.dll", ExactSpelling:=True)>
Public Shared Function IERegSetValueEx(
<MarshalAs(UnmanagedType.LPWStr)> lpSubKey As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpValueName As String, ' LPCWSTR
Reserved As UInteger, ' DWORD
dwType As UInteger, ' DWORD
lpData As IntPtr, ' BYTE*
cbData As UInteger ' DWORD
) As Integer
End Function' lpSubKey : LPCWSTR
' lpValueName : LPCWSTR
' Reserved : DWORD
' dwType : DWORD
' lpData : BYTE*
' cbData : DWORD
Declare PtrSafe Function IERegSetValueEx Lib "ieframe" ( _
ByVal lpSubKey As LongPtr, _
ByVal lpValueName As LongPtr, _
ByVal Reserved As Long, _
ByVal dwType As Long, _
ByVal lpData As LongPtr, _
ByVal cbData As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IERegSetValueEx = ctypes.windll.ieframe.IERegSetValueEx
IERegSetValueEx.restype = ctypes.c_int
IERegSetValueEx.argtypes = [
wintypes.LPCWSTR, # lpSubKey : LPCWSTR
wintypes.LPCWSTR, # lpValueName : LPCWSTR
wintypes.DWORD, # Reserved : DWORD
wintypes.DWORD, # dwType : DWORD
ctypes.POINTER(ctypes.c_ubyte), # lpData : BYTE*
wintypes.DWORD, # cbData : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('Ieframe.dll')
IERegSetValueEx = Fiddle::Function.new(
lib['IERegSetValueEx'],
[
Fiddle::TYPE_VOIDP, # lpSubKey : LPCWSTR
Fiddle::TYPE_VOIDP, # lpValueName : LPCWSTR
-Fiddle::TYPE_INT, # Reserved : DWORD
-Fiddle::TYPE_INT, # dwType : DWORD
Fiddle::TYPE_VOIDP, # lpData : BYTE*
-Fiddle::TYPE_INT, # cbData : DWORD
],
Fiddle::TYPE_INT)#[link(name = "ieframe")]
extern "system" {
fn IERegSetValueEx(
lpSubKey: *const u16, // LPCWSTR
lpValueName: *const u16, // LPCWSTR
Reserved: u32, // DWORD
dwType: u32, // DWORD
lpData: *const u8, // BYTE*
cbData: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("Ieframe.dll")]
public static extern int IERegSetValueEx([MarshalAs(UnmanagedType.LPWStr)] string lpSubKey, [MarshalAs(UnmanagedType.LPWStr)] string lpValueName, uint Reserved, uint dwType, IntPtr lpData, uint cbData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Ieframe_IERegSetValueEx' -Namespace Win32 -PassThru
# $api::IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, lpData, cbData)#uselib "Ieframe.dll"
#func global IERegSetValueEx "IERegSetValueEx" sptr, sptr, sptr, sptr, sptr, sptr
; IERegSetValueEx lpSubKey, lpValueName, Reserved, dwType, varptr(lpData), cbData ; 戻り値は stat
; lpSubKey : LPCWSTR -> "sptr"
; lpValueName : LPCWSTR -> "sptr"
; Reserved : DWORD -> "sptr"
; dwType : DWORD -> "sptr"
; lpData : BYTE* -> "sptr"
; cbData : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "Ieframe.dll" #cfunc global IERegSetValueEx "IERegSetValueEx" wstr, wstr, int, int, var, int ; res = IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, lpData, cbData) ; lpSubKey : LPCWSTR -> "wstr" ; lpValueName : LPCWSTR -> "wstr" ; Reserved : DWORD -> "int" ; dwType : DWORD -> "int" ; lpData : BYTE* -> "var" ; cbData : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "Ieframe.dll" #cfunc global IERegSetValueEx "IERegSetValueEx" wstr, wstr, int, int, sptr, int ; res = IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, varptr(lpData), cbData) ; lpSubKey : LPCWSTR -> "wstr" ; lpValueName : LPCWSTR -> "wstr" ; Reserved : DWORD -> "int" ; dwType : DWORD -> "int" ; lpData : BYTE* -> "sptr" ; cbData : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT IERegSetValueEx(LPCWSTR lpSubKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData) #uselib "Ieframe.dll" #cfunc global IERegSetValueEx "IERegSetValueEx" wstr, wstr, int, int, var, int ; res = IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, lpData, cbData) ; lpSubKey : LPCWSTR -> "wstr" ; lpValueName : LPCWSTR -> "wstr" ; Reserved : DWORD -> "int" ; dwType : DWORD -> "int" ; lpData : BYTE* -> "var" ; cbData : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT IERegSetValueEx(LPCWSTR lpSubKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData) #uselib "Ieframe.dll" #cfunc global IERegSetValueEx "IERegSetValueEx" wstr, wstr, int, int, intptr, int ; res = IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, varptr(lpData), cbData) ; lpSubKey : LPCWSTR -> "wstr" ; lpValueName : LPCWSTR -> "wstr" ; Reserved : DWORD -> "int" ; dwType : DWORD -> "int" ; lpData : BYTE* -> "intptr" ; cbData : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ieframe = windows.NewLazySystemDLL("Ieframe.dll")
procIERegSetValueEx = ieframe.NewProc("IERegSetValueEx")
)
// lpSubKey (LPCWSTR), lpValueName (LPCWSTR), Reserved (DWORD), dwType (DWORD), lpData (BYTE*), cbData (DWORD)
r1, _, err := procIERegSetValueEx.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpSubKey))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpValueName))),
uintptr(Reserved),
uintptr(dwType),
uintptr(lpData),
uintptr(cbData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction IERegSetValueEx(
lpSubKey: PWideChar; // LPCWSTR
lpValueName: PWideChar; // LPCWSTR
Reserved: DWORD; // DWORD
dwType: DWORD; // DWORD
lpData: Pointer; // BYTE*
cbData: DWORD // DWORD
): Integer; stdcall;
external 'Ieframe.dll' name 'IERegSetValueEx';result := DllCall("Ieframe\IERegSetValueEx"
, "WStr", lpSubKey ; LPCWSTR
, "WStr", lpValueName ; LPCWSTR
, "UInt", Reserved ; DWORD
, "UInt", dwType ; DWORD
, "Ptr", lpData ; BYTE*
, "UInt", cbData ; DWORD
, "Int") ; return: HRESULT●IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, lpData, cbData) = DLL("Ieframe.dll", "int IERegSetValueEx(char*, char*, dword, dword, void*, dword)")
# 呼び出し: IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, lpData, cbData)
# lpSubKey : LPCWSTR -> "char*"
# lpValueName : LPCWSTR -> "char*"
# Reserved : DWORD -> "dword"
# dwType : DWORD -> "dword"
# lpData : BYTE* -> "void*"
# cbData : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ieframe" fn IERegSetValueEx(
lpSubKey: [*c]const u16, // LPCWSTR
lpValueName: [*c]const u16, // LPCWSTR
Reserved: u32, // DWORD
dwType: u32, // DWORD
lpData: [*c]u8, // BYTE*
cbData: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc IERegSetValueEx(
lpSubKey: WideCString, # LPCWSTR
lpValueName: WideCString, # LPCWSTR
Reserved: uint32, # DWORD
dwType: uint32, # DWORD
lpData: ptr uint8, # BYTE*
cbData: uint32 # DWORD
): int32 {.importc: "IERegSetValueEx", stdcall, dynlib: "Ieframe.dll".}pragma(lib, "ieframe");
extern(Windows)
int IERegSetValueEx(
const(wchar)* lpSubKey, // LPCWSTR
const(wchar)* lpValueName, // LPCWSTR
uint Reserved, // DWORD
uint dwType, // DWORD
ubyte* lpData, // BYTE*
uint cbData // DWORD
);ccall((:IERegSetValueEx, "Ieframe.dll"), stdcall, Int32,
(Cwstring, Cwstring, UInt32, UInt32, Ptr{UInt8}, UInt32),
lpSubKey, lpValueName, Reserved, dwType, lpData, cbData)
# lpSubKey : LPCWSTR -> Cwstring
# lpValueName : LPCWSTR -> Cwstring
# Reserved : DWORD -> UInt32
# dwType : DWORD -> UInt32
# lpData : BYTE* -> Ptr{UInt8}
# cbData : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t IERegSetValueEx(
const uint16_t* lpSubKey,
const uint16_t* lpValueName,
uint32_t Reserved,
uint32_t dwType,
uint8_t* lpData,
uint32_t cbData);
]]
local ieframe = ffi.load("ieframe")
-- ieframe.IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, lpData, cbData)
-- lpSubKey : LPCWSTR
-- lpValueName : LPCWSTR
-- Reserved : DWORD
-- dwType : DWORD
-- lpData : BYTE*
-- cbData : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('Ieframe.dll');
const IERegSetValueEx = lib.func('__stdcall', 'IERegSetValueEx', 'int32_t', ['str16', 'str16', 'uint32_t', 'uint32_t', 'uint8_t *', 'uint32_t']);
// IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, lpData, cbData)
// lpSubKey : LPCWSTR -> 'str16'
// lpValueName : LPCWSTR -> 'str16'
// Reserved : DWORD -> 'uint32_t'
// dwType : DWORD -> 'uint32_t'
// lpData : BYTE* -> 'uint8_t *'
// cbData : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("Ieframe.dll", {
IERegSetValueEx: { parameters: ["buffer", "buffer", "u32", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, lpData, cbData)
// lpSubKey : LPCWSTR -> "buffer"
// lpValueName : LPCWSTR -> "buffer"
// Reserved : DWORD -> "u32"
// dwType : DWORD -> "u32"
// lpData : BYTE* -> "pointer"
// cbData : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t IERegSetValueEx(
const uint16_t* lpSubKey,
const uint16_t* lpValueName,
uint32_t Reserved,
uint32_t dwType,
uint8_t* lpData,
uint32_t cbData);
C, "Ieframe.dll");
// $ffi->IERegSetValueEx(lpSubKey, lpValueName, Reserved, dwType, lpData, cbData);
// lpSubKey : LPCWSTR
// lpValueName : LPCWSTR
// Reserved : DWORD
// dwType : DWORD
// lpData : BYTE*
// cbData : DWORD
// 構造体/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 IERegSetValueEx(
WString lpSubKey, // LPCWSTR
WString lpValueName, // LPCWSTR
int Reserved, // DWORD
int dwType, // DWORD
byte[] lpData, // BYTE*
int cbData // DWORD
);
}@[Link("ieframe")]
lib LibIeframe
fun IERegSetValueEx = IERegSetValueEx(
lpSubKey : UInt16*, # LPCWSTR
lpValueName : UInt16*, # LPCWSTR
Reserved : UInt32, # DWORD
dwType : UInt32, # DWORD
lpData : UInt8*, # BYTE*
cbData : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef IERegSetValueExNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Uint32, Pointer<Uint8>, Uint32);
typedef IERegSetValueExDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, int, Pointer<Uint8>, int);
final IERegSetValueEx = DynamicLibrary.open('Ieframe.dll')
.lookupFunction<IERegSetValueExNative, IERegSetValueExDart>('IERegSetValueEx');
// lpSubKey : LPCWSTR -> Pointer<Utf16>
// lpValueName : LPCWSTR -> Pointer<Utf16>
// Reserved : DWORD -> Uint32
// dwType : DWORD -> Uint32
// lpData : BYTE* -> Pointer<Uint8>
// cbData : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function IERegSetValueEx(
lpSubKey: PWideChar; // LPCWSTR
lpValueName: PWideChar; // LPCWSTR
Reserved: DWORD; // DWORD
dwType: DWORD; // DWORD
lpData: Pointer; // BYTE*
cbData: DWORD // DWORD
): Integer; stdcall;
external 'Ieframe.dll' name 'IERegSetValueEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "IERegSetValueEx"
c_IERegSetValueEx :: CWString -> CWString -> Word32 -> Word32 -> Ptr Word8 -> Word32 -> IO Int32
-- lpSubKey : LPCWSTR -> CWString
-- lpValueName : LPCWSTR -> CWString
-- Reserved : DWORD -> Word32
-- dwType : DWORD -> Word32
-- lpData : BYTE* -> Ptr Word8
-- cbData : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ieregsetvalueex =
foreign "IERegSetValueEx"
((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> returning int32_t)
(* lpSubKey : LPCWSTR -> (ptr uint16_t) *)
(* lpValueName : LPCWSTR -> (ptr uint16_t) *)
(* Reserved : DWORD -> uint32_t *)
(* dwType : DWORD -> uint32_t *)
(* lpData : BYTE* -> (ptr uint8_t) *)
(* cbData : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ieframe (t "Ieframe.dll"))
(cffi:use-foreign-library ieframe)
(cffi:defcfun ("IERegSetValueEx" iereg-set-value-ex :convention :stdcall) :int32
(lp-sub-key (:string :encoding :utf-16le)) ; LPCWSTR
(lp-value-name (:string :encoding :utf-16le)) ; LPCWSTR
(reserved :uint32) ; DWORD
(dw-type :uint32) ; DWORD
(lp-data :pointer) ; BYTE*
(cb-data :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $IERegSetValueEx = Win32::API::More->new('Ieframe',
'int IERegSetValueEx(LPCWSTR lpSubKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, LPVOID lpData, DWORD cbData)');
# my $ret = $IERegSetValueEx->Call($lpSubKey, $lpValueName, $Reserved, $dwType, $lpData, $cbData);
# lpSubKey : LPCWSTR -> LPCWSTR
# lpValueName : LPCWSTR -> LPCWSTR
# Reserved : DWORD -> DWORD
# dwType : DWORD -> DWORD
# lpData : BYTE* -> LPVOID
# cbData : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。