ホーム › System.WindowsProgramming › RegInstallW
RegInstallW
関数INFのレジストリセクションをインストールする(Unicode版)。
シグネチャ
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT RegInstallW(
HMODULE hmod,
LPCWSTR pszSection,
const STRTABLEW* pstTable
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hmod | HMODULE | in |
| pszSection | LPCWSTR | in |
| pstTable | STRTABLEW* | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT RegInstallW(
HMODULE hmod,
LPCWSTR pszSection,
const STRTABLEW* pstTable
);[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RegInstallW(
IntPtr hmod, // HMODULE
[MarshalAs(UnmanagedType.LPWStr)] string pszSection, // LPCWSTR
IntPtr pstTable // STRTABLEW*
);<DllImport("ADVPACK.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RegInstallW(
hmod As IntPtr, ' HMODULE
<MarshalAs(UnmanagedType.LPWStr)> pszSection As String, ' LPCWSTR
pstTable As IntPtr ' STRTABLEW*
) As Integer
End Function' hmod : HMODULE
' pszSection : LPCWSTR
' pstTable : STRTABLEW*
Declare PtrSafe Function RegInstallW Lib "advpack" ( _
ByVal hmod As LongPtr, _
ByVal pszSection As LongPtr, _
ByVal pstTable As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegInstallW = ctypes.windll.advpack.RegInstallW
RegInstallW.restype = ctypes.c_int
RegInstallW.argtypes = [
wintypes.HANDLE, # hmod : HMODULE
wintypes.LPCWSTR, # pszSection : LPCWSTR
ctypes.c_void_p, # pstTable : STRTABLEW*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVPACK.dll')
RegInstallW = Fiddle::Function.new(
lib['RegInstallW'],
[
Fiddle::TYPE_VOIDP, # hmod : HMODULE
Fiddle::TYPE_VOIDP, # pszSection : LPCWSTR
Fiddle::TYPE_VOIDP, # pstTable : STRTABLEW*
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advpack")]
extern "system" {
fn RegInstallW(
hmod: *mut core::ffi::c_void, // HMODULE
pszSection: *const u16, // LPCWSTR
pstTable: *const STRTABLEW // STRTABLEW*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode)]
public static extern int RegInstallW(IntPtr hmod, [MarshalAs(UnmanagedType.LPWStr)] string pszSection, IntPtr pstTable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_RegInstallW' -Namespace Win32 -PassThru
# $api::RegInstallW(hmod, pszSection, pstTable)#uselib "ADVPACK.dll"
#func global RegInstallW "RegInstallW" wptr, wptr, wptr
; RegInstallW hmod, pszSection, varptr(pstTable) ; 戻り値は stat
; hmod : HMODULE -> "wptr"
; pszSection : LPCWSTR -> "wptr"
; pstTable : STRTABLEW* -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVPACK.dll" #cfunc global RegInstallW "RegInstallW" sptr, wstr, var ; res = RegInstallW(hmod, pszSection, pstTable) ; hmod : HMODULE -> "sptr" ; pszSection : LPCWSTR -> "wstr" ; pstTable : STRTABLEW* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVPACK.dll" #cfunc global RegInstallW "RegInstallW" sptr, wstr, sptr ; res = RegInstallW(hmod, pszSection, varptr(pstTable)) ; hmod : HMODULE -> "sptr" ; pszSection : LPCWSTR -> "wstr" ; pstTable : STRTABLEW* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT RegInstallW(HMODULE hmod, LPCWSTR pszSection, STRTABLEW* pstTable) #uselib "ADVPACK.dll" #cfunc global RegInstallW "RegInstallW" intptr, wstr, var ; res = RegInstallW(hmod, pszSection, pstTable) ; hmod : HMODULE -> "intptr" ; pszSection : LPCWSTR -> "wstr" ; pstTable : STRTABLEW* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT RegInstallW(HMODULE hmod, LPCWSTR pszSection, STRTABLEW* pstTable) #uselib "ADVPACK.dll" #cfunc global RegInstallW "RegInstallW" intptr, wstr, intptr ; res = RegInstallW(hmod, pszSection, varptr(pstTable)) ; hmod : HMODULE -> "intptr" ; pszSection : LPCWSTR -> "wstr" ; pstTable : STRTABLEW* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advpack = windows.NewLazySystemDLL("ADVPACK.dll")
procRegInstallW = advpack.NewProc("RegInstallW")
)
// hmod (HMODULE), pszSection (LPCWSTR), pstTable (STRTABLEW*)
r1, _, err := procRegInstallW.Call(
uintptr(hmod),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszSection))),
uintptr(pstTable),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RegInstallW(
hmod: THandle; // HMODULE
pszSection: PWideChar; // LPCWSTR
pstTable: Pointer // STRTABLEW*
): Integer; stdcall;
external 'ADVPACK.dll' name 'RegInstallW';result := DllCall("ADVPACK\RegInstallW"
, "Ptr", hmod ; HMODULE
, "WStr", pszSection ; LPCWSTR
, "Ptr", pstTable ; STRTABLEW*
, "Int") ; return: HRESULT●RegInstallW(hmod, pszSection, pstTable) = DLL("ADVPACK.dll", "int RegInstallW(void*, char*, void*)")
# 呼び出し: RegInstallW(hmod, pszSection, pstTable)
# hmod : HMODULE -> "void*"
# pszSection : LPCWSTR -> "char*"
# pstTable : STRTABLEW* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。