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

MsiGetComponentStateA

関数
コンポーネントの現在の状態と要求された状態を取得する(ANSI版)。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiGetComponentStateA(
    MSIHANDLE hInstall,
    LPCSTR szComponent,
    INSTALLSTATE* piInstalled,
    INSTALLSTATE* piAction
);

パラメーター

名前方向
hInstallMSIHANDLEin
szComponentLPCSTRin
piInstalledINSTALLSTATE*inout
piActionINSTALLSTATE*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiGetComponentStateA(
    MSIHANDLE hInstall,
    LPCSTR szComponent,
    INSTALLSTATE* piInstalled,
    INSTALLSTATE* piAction
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiGetComponentStateA(
    uint hInstall,   // MSIHANDLE
    [MarshalAs(UnmanagedType.LPStr)] string szComponent,   // LPCSTR
    ref int piInstalled,   // INSTALLSTATE* in/out
    ref int piAction   // INSTALLSTATE* in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiGetComponentStateA(
    hInstall As UInteger,   ' MSIHANDLE
    <MarshalAs(UnmanagedType.LPStr)> szComponent As String,   ' LPCSTR
    ByRef piInstalled As Integer,   ' INSTALLSTATE* in/out
    ByRef piAction As Integer   ' INSTALLSTATE* in/out
) As UInteger
End Function
' hInstall : MSIHANDLE
' szComponent : LPCSTR
' piInstalled : INSTALLSTATE* in/out
' piAction : INSTALLSTATE* in/out
Declare PtrSafe Function MsiGetComponentStateA Lib "msi" ( _
    ByVal hInstall As Long, _
    ByVal szComponent As String, _
    ByRef piInstalled As Long, _
    ByRef piAction As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MsiGetComponentStateA = ctypes.windll.msi.MsiGetComponentStateA
MsiGetComponentStateA.restype = wintypes.DWORD
MsiGetComponentStateA.argtypes = [
    wintypes.DWORD,  # hInstall : MSIHANDLE
    wintypes.LPCSTR,  # szComponent : LPCSTR
    ctypes.c_void_p,  # piInstalled : INSTALLSTATE* in/out
    ctypes.c_void_p,  # piAction : INSTALLSTATE* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiGetComponentStateA = Fiddle::Function.new(
  lib['MsiGetComponentStateA'],
  [
    -Fiddle::TYPE_INT,  # hInstall : MSIHANDLE
    Fiddle::TYPE_VOIDP,  # szComponent : LPCSTR
    Fiddle::TYPE_VOIDP,  # piInstalled : INSTALLSTATE* in/out
    Fiddle::TYPE_VOIDP,  # piAction : INSTALLSTATE* in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "msi")]
extern "system" {
    fn MsiGetComponentStateA(
        hInstall: u32,  // MSIHANDLE
        szComponent: *const u8,  // LPCSTR
        piInstalled: *mut i32,  // INSTALLSTATE* in/out
        piAction: *mut i32  // INSTALLSTATE* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiGetComponentStateA(uint hInstall, [MarshalAs(UnmanagedType.LPStr)] string szComponent, ref int piInstalled, ref int piAction);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetComponentStateA' -Namespace Win32 -PassThru
# $api::MsiGetComponentStateA(hInstall, szComponent, piInstalled, piAction)
#uselib "msi.dll"
#func global MsiGetComponentStateA "MsiGetComponentStateA" sptr, sptr, sptr, sptr
; MsiGetComponentStateA hInstall, szComponent, piInstalled, piAction   ; 戻り値は stat
; hInstall : MSIHANDLE -> "sptr"
; szComponent : LPCSTR -> "sptr"
; piInstalled : INSTALLSTATE* in/out -> "sptr"
; piAction : INSTALLSTATE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiGetComponentStateA "MsiGetComponentStateA" int, str, int, int
; res = MsiGetComponentStateA(hInstall, szComponent, piInstalled, piAction)
; hInstall : MSIHANDLE -> "int"
; szComponent : LPCSTR -> "str"
; piInstalled : INSTALLSTATE* in/out -> "int"
; piAction : INSTALLSTATE* in/out -> "int"
; DWORD MsiGetComponentStateA(MSIHANDLE hInstall, LPCSTR szComponent, INSTALLSTATE* piInstalled, INSTALLSTATE* piAction)
#uselib "msi.dll"
#cfunc global MsiGetComponentStateA "MsiGetComponentStateA" int, str, int, int
; res = MsiGetComponentStateA(hInstall, szComponent, piInstalled, piAction)
; hInstall : MSIHANDLE -> "int"
; szComponent : LPCSTR -> "str"
; piInstalled : INSTALLSTATE* in/out -> "int"
; piAction : INSTALLSTATE* in/out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiGetComponentStateA = msi.NewProc("MsiGetComponentStateA")
)

// hInstall (MSIHANDLE), szComponent (LPCSTR), piInstalled (INSTALLSTATE* in/out), piAction (INSTALLSTATE* in/out)
r1, _, err := procMsiGetComponentStateA.Call(
	uintptr(hInstall),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szComponent))),
	uintptr(piInstalled),
	uintptr(piAction),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiGetComponentStateA(
  hInstall: DWORD;   // MSIHANDLE
  szComponent: PAnsiChar;   // LPCSTR
  piInstalled: Pointer;   // INSTALLSTATE* in/out
  piAction: Pointer   // INSTALLSTATE* in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiGetComponentStateA';
result := DllCall("msi\MsiGetComponentStateA"
    , "UInt", hInstall   ; MSIHANDLE
    , "AStr", szComponent   ; LPCSTR
    , "Ptr", piInstalled   ; INSTALLSTATE* in/out
    , "Ptr", piAction   ; INSTALLSTATE* in/out
    , "UInt")   ; return: DWORD
●MsiGetComponentStateA(hInstall, szComponent, piInstalled, piAction) = DLL("msi.dll", "dword MsiGetComponentStateA(dword, char*, void*, void*)")
# 呼び出し: MsiGetComponentStateA(hInstall, szComponent, piInstalled, piAction)
# hInstall : MSIHANDLE -> "dword"
# szComponent : LPCSTR -> "char*"
# piInstalled : INSTALLSTATE* in/out -> "void*"
# piAction : INSTALLSTATE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。