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

RegInstallA

関数
INFのレジストリセクションをインストールする(ANSI版)。
DLLADVPACK.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 10 以降

シグネチャ

// ADVPACK.dll  (ANSI / -A)
#include <windows.h>

HRESULT RegInstallA(
    HMODULE hmod,
    LPCSTR pszSection,
    const STRTABLEA* pstTable
);

パラメーター

名前方向
hmodHMODULEin
pszSectionLPCSTRin
pstTableSTRTABLEA*in

戻り値の型: HRESULT

各言語での呼び出し定義

// ADVPACK.dll  (ANSI / -A)
#include <windows.h>

HRESULT RegInstallA(
    HMODULE hmod,
    LPCSTR pszSection,
    const STRTABLEA* pstTable
);
[DllImport("ADVPACK.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int RegInstallA(
    IntPtr hmod,   // HMODULE
    [MarshalAs(UnmanagedType.LPStr)] string pszSection,   // LPCSTR
    IntPtr pstTable   // STRTABLEA*
);
<DllImport("ADVPACK.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RegInstallA(
    hmod As IntPtr,   ' HMODULE
    <MarshalAs(UnmanagedType.LPStr)> pszSection As String,   ' LPCSTR
    pstTable As IntPtr   ' STRTABLEA*
) As Integer
End Function
' hmod : HMODULE
' pszSection : LPCSTR
' pstTable : STRTABLEA*
Declare PtrSafe Function RegInstallA Lib "advpack" ( _
    ByVal hmod As LongPtr, _
    ByVal pszSection As String, _
    ByVal pstTable As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RegInstallA = ctypes.windll.advpack.RegInstallA
RegInstallA.restype = ctypes.c_int
RegInstallA.argtypes = [
    wintypes.HANDLE,  # hmod : HMODULE
    wintypes.LPCSTR,  # pszSection : LPCSTR
    ctypes.c_void_p,  # pstTable : STRTABLEA*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVPACK.dll')
RegInstallA = Fiddle::Function.new(
  lib['RegInstallA'],
  [
    Fiddle::TYPE_VOIDP,  # hmod : HMODULE
    Fiddle::TYPE_VOIDP,  # pszSection : LPCSTR
    Fiddle::TYPE_VOIDP,  # pstTable : STRTABLEA*
  ],
  Fiddle::TYPE_INT)
#[link(name = "advpack")]
extern "system" {
    fn RegInstallA(
        hmod: *mut core::ffi::c_void,  // HMODULE
        pszSection: *const u8,  // LPCSTR
        pstTable: *const STRTABLEA  // STRTABLEA*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVPACK.dll", CharSet = CharSet.Ansi)]
public static extern int RegInstallA(IntPtr hmod, [MarshalAs(UnmanagedType.LPStr)] string pszSection, IntPtr pstTable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_RegInstallA' -Namespace Win32 -PassThru
# $api::RegInstallA(hmod, pszSection, pstTable)
#uselib "ADVPACK.dll"
#func global RegInstallA "RegInstallA" sptr, sptr, sptr
; RegInstallA hmod, pszSection, varptr(pstTable)   ; 戻り値は stat
; hmod : HMODULE -> "sptr"
; pszSection : LPCSTR -> "sptr"
; pstTable : STRTABLEA* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ADVPACK.dll"
#cfunc global RegInstallA "RegInstallA" sptr, str, var
; res = RegInstallA(hmod, pszSection, pstTable)
; hmod : HMODULE -> "sptr"
; pszSection : LPCSTR -> "str"
; pstTable : STRTABLEA* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT RegInstallA(HMODULE hmod, LPCSTR pszSection, STRTABLEA* pstTable)
#uselib "ADVPACK.dll"
#cfunc global RegInstallA "RegInstallA" intptr, str, var
; res = RegInstallA(hmod, pszSection, pstTable)
; hmod : HMODULE -> "intptr"
; pszSection : LPCSTR -> "str"
; pstTable : STRTABLEA* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advpack = windows.NewLazySystemDLL("ADVPACK.dll")
	procRegInstallA = advpack.NewProc("RegInstallA")
)

// hmod (HMODULE), pszSection (LPCSTR), pstTable (STRTABLEA*)
r1, _, err := procRegInstallA.Call(
	uintptr(hmod),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pszSection))),
	uintptr(pstTable),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function RegInstallA(
  hmod: THandle;   // HMODULE
  pszSection: PAnsiChar;   // LPCSTR
  pstTable: Pointer   // STRTABLEA*
): Integer; stdcall;
  external 'ADVPACK.dll' name 'RegInstallA';
result := DllCall("ADVPACK\RegInstallA"
    , "Ptr", hmod   ; HMODULE
    , "AStr", pszSection   ; LPCSTR
    , "Ptr", pstTable   ; STRTABLEA*
    , "Int")   ; return: HRESULT
●RegInstallA(hmod, pszSection, pstTable) = DLL("ADVPACK.dll", "int RegInstallA(void*, char*, void*)")
# 呼び出し: RegInstallA(hmod, pszSection, pstTable)
# hmod : HMODULE -> "void*"
# pszSection : LPCSTR -> "char*"
# pstTable : STRTABLEA* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。