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

MsiGetComponentPathExA

関数
インストールコンテキストとユーザーSIDを指定してコンポーネントのパスと状態を取得する。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

INSTALLSTATE MsiGetComponentPathExA(
    LPCSTR szProductCode,
    LPCSTR szComponentCode,
    LPCSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,   // optional
    LPSTR lpOutPathBuffer,   // optional
    DWORD* pcchOutPathBuffer   // optional
);

パラメーター

名前方向
szProductCodeLPCSTRin
szComponentCodeLPCSTRin
szUserSidLPCSTRinoptional
dwContextMSIINSTALLCONTEXTinoptional
lpOutPathBufferLPSTRoutoptional
pcchOutPathBufferDWORD*inoutoptional

戻り値の型: INSTALLSTATE

各言語での呼び出し定義

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

INSTALLSTATE MsiGetComponentPathExA(
    LPCSTR szProductCode,
    LPCSTR szComponentCode,
    LPCSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,   // optional
    LPSTR lpOutPathBuffer,   // optional
    DWORD* pcchOutPathBuffer   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int MsiGetComponentPathExA(
    [MarshalAs(UnmanagedType.LPStr)] string szProductCode,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string szComponentCode,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string szUserSid,   // LPCSTR optional
    int dwContext,   // MSIINSTALLCONTEXT optional
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpOutPathBuffer,   // LPSTR optional, out
    IntPtr pcchOutPathBuffer   // DWORD* optional, in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiGetComponentPathExA(
    <MarshalAs(UnmanagedType.LPStr)> szProductCode As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> szComponentCode As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> szUserSid As String,   ' LPCSTR optional
    dwContext As Integer,   ' MSIINSTALLCONTEXT optional
    <MarshalAs(UnmanagedType.LPStr)> lpOutPathBuffer As System.Text.StringBuilder,   ' LPSTR optional, out
    pcchOutPathBuffer As IntPtr   ' DWORD* optional, in/out
) As Integer
End Function
' szProductCode : LPCSTR
' szComponentCode : LPCSTR
' szUserSid : LPCSTR optional
' dwContext : MSIINSTALLCONTEXT optional
' lpOutPathBuffer : LPSTR optional, out
' pcchOutPathBuffer : DWORD* optional, in/out
Declare PtrSafe Function MsiGetComponentPathExA Lib "msi" ( _
    ByVal szProductCode As String, _
    ByVal szComponentCode As String, _
    ByVal szUserSid As String, _
    ByVal dwContext As Long, _
    ByVal lpOutPathBuffer As String, _
    ByVal pcchOutPathBuffer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MsiGetComponentPathExA = ctypes.windll.msi.MsiGetComponentPathExA
MsiGetComponentPathExA.restype = ctypes.c_int
MsiGetComponentPathExA.argtypes = [
    wintypes.LPCSTR,  # szProductCode : LPCSTR
    wintypes.LPCSTR,  # szComponentCode : LPCSTR
    wintypes.LPCSTR,  # szUserSid : LPCSTR optional
    ctypes.c_int,  # dwContext : MSIINSTALLCONTEXT optional
    wintypes.LPSTR,  # lpOutPathBuffer : LPSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchOutPathBuffer : DWORD* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiGetComponentPathExA = Fiddle::Function.new(
  lib['MsiGetComponentPathExA'],
  [
    Fiddle::TYPE_VOIDP,  # szProductCode : LPCSTR
    Fiddle::TYPE_VOIDP,  # szComponentCode : LPCSTR
    Fiddle::TYPE_VOIDP,  # szUserSid : LPCSTR optional
    Fiddle::TYPE_INT,  # dwContext : MSIINSTALLCONTEXT optional
    Fiddle::TYPE_VOIDP,  # lpOutPathBuffer : LPSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcchOutPathBuffer : DWORD* optional, in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "msi")]
extern "system" {
    fn MsiGetComponentPathExA(
        szProductCode: *const u8,  // LPCSTR
        szComponentCode: *const u8,  // LPCSTR
        szUserSid: *const u8,  // LPCSTR optional
        dwContext: i32,  // MSIINSTALLCONTEXT optional
        lpOutPathBuffer: *mut u8,  // LPSTR optional, out
        pcchOutPathBuffer: *mut u32  // DWORD* optional, in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern int MsiGetComponentPathExA([MarshalAs(UnmanagedType.LPStr)] string szProductCode, [MarshalAs(UnmanagedType.LPStr)] string szComponentCode, [MarshalAs(UnmanagedType.LPStr)] string szUserSid, int dwContext, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpOutPathBuffer, IntPtr pcchOutPathBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetComponentPathExA' -Namespace Win32 -PassThru
# $api::MsiGetComponentPathExA(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer)
#uselib "msi.dll"
#func global MsiGetComponentPathExA "MsiGetComponentPathExA" sptr, sptr, sptr, sptr, sptr, sptr
; MsiGetComponentPathExA szProductCode, szComponentCode, szUserSid, dwContext, varptr(lpOutPathBuffer), varptr(pcchOutPathBuffer)   ; 戻り値は stat
; szProductCode : LPCSTR -> "sptr"
; szComponentCode : LPCSTR -> "sptr"
; szUserSid : LPCSTR optional -> "sptr"
; dwContext : MSIINSTALLCONTEXT optional -> "sptr"
; lpOutPathBuffer : LPSTR optional, out -> "sptr"
; pcchOutPathBuffer : DWORD* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiGetComponentPathExA "MsiGetComponentPathExA" str, str, str, int, var, var
; res = MsiGetComponentPathExA(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer)
; szProductCode : LPCSTR -> "str"
; szComponentCode : LPCSTR -> "str"
; szUserSid : LPCSTR optional -> "str"
; dwContext : MSIINSTALLCONTEXT optional -> "int"
; lpOutPathBuffer : LPSTR optional, out -> "var"
; pcchOutPathBuffer : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INSTALLSTATE MsiGetComponentPathExA(LPCSTR szProductCode, LPCSTR szComponentCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPSTR lpOutPathBuffer, DWORD* pcchOutPathBuffer)
#uselib "msi.dll"
#cfunc global MsiGetComponentPathExA "MsiGetComponentPathExA" str, str, str, int, var, var
; res = MsiGetComponentPathExA(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer)
; szProductCode : LPCSTR -> "str"
; szComponentCode : LPCSTR -> "str"
; szUserSid : LPCSTR optional -> "str"
; dwContext : MSIINSTALLCONTEXT optional -> "int"
; lpOutPathBuffer : LPSTR optional, out -> "var"
; pcchOutPathBuffer : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiGetComponentPathExA = msi.NewProc("MsiGetComponentPathExA")
)

// szProductCode (LPCSTR), szComponentCode (LPCSTR), szUserSid (LPCSTR optional), dwContext (MSIINSTALLCONTEXT optional), lpOutPathBuffer (LPSTR optional, out), pcchOutPathBuffer (DWORD* optional, in/out)
r1, _, err := procMsiGetComponentPathExA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szProductCode))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szComponentCode))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szUserSid))),
	uintptr(dwContext),
	uintptr(lpOutPathBuffer),
	uintptr(pcchOutPathBuffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INSTALLSTATE
function MsiGetComponentPathExA(
  szProductCode: PAnsiChar;   // LPCSTR
  szComponentCode: PAnsiChar;   // LPCSTR
  szUserSid: PAnsiChar;   // LPCSTR optional
  dwContext: Integer;   // MSIINSTALLCONTEXT optional
  lpOutPathBuffer: PAnsiChar;   // LPSTR optional, out
  pcchOutPathBuffer: Pointer   // DWORD* optional, in/out
): Integer; stdcall;
  external 'msi.dll' name 'MsiGetComponentPathExA';
result := DllCall("msi\MsiGetComponentPathExA"
    , "AStr", szProductCode   ; LPCSTR
    , "AStr", szComponentCode   ; LPCSTR
    , "AStr", szUserSid   ; LPCSTR optional
    , "Int", dwContext   ; MSIINSTALLCONTEXT optional
    , "Ptr", lpOutPathBuffer   ; LPSTR optional, out
    , "Ptr", pcchOutPathBuffer   ; DWORD* optional, in/out
    , "Int")   ; return: INSTALLSTATE
●MsiGetComponentPathExA(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer) = DLL("msi.dll", "int MsiGetComponentPathExA(char*, char*, char*, int, char*, void*)")
# 呼び出し: MsiGetComponentPathExA(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer)
# szProductCode : LPCSTR -> "char*"
# szComponentCode : LPCSTR -> "char*"
# szUserSid : LPCSTR optional -> "char*"
# dwContext : MSIINSTALLCONTEXT optional -> "int"
# lpOutPathBuffer : LPSTR optional, out -> "char*"
# pcchOutPathBuffer : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。