ホーム › System.ApplicationInstallationAndServicing › MsiGetComponentPathExW
MsiGetComponentPathExW
関数インストールコンテキストとユーザーSIDを指定してコンポーネントのパスと状態を取得する。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
INSTALLSTATE MsiGetComponentPathExW(
LPCWSTR szProductCode,
LPCWSTR szComponentCode,
LPCWSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext, // optional
LPWSTR lpOutPathBuffer, // optional
DWORD* pcchOutPathBuffer // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szProductCode | LPCWSTR | in |
| szComponentCode | LPCWSTR | in |
| szUserSid | LPCWSTR | inoptional |
| dwContext | MSIINSTALLCONTEXT | inoptional |
| lpOutPathBuffer | LPWSTR | outoptional |
| pcchOutPathBuffer | DWORD* | inoutoptional |
戻り値の型: INSTALLSTATE
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
INSTALLSTATE MsiGetComponentPathExW(
LPCWSTR szProductCode,
LPCWSTR szComponentCode,
LPCWSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext, // optional
LPWSTR lpOutPathBuffer, // optional
DWORD* pcchOutPathBuffer // optional
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int MsiGetComponentPathExW(
[MarshalAs(UnmanagedType.LPWStr)] string szProductCode, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szComponentCode, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szUserSid, // LPCWSTR optional
int dwContext, // MSIINSTALLCONTEXT optional
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpOutPathBuffer, // LPWSTR optional, out
IntPtr pcchOutPathBuffer // DWORD* optional, in/out
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiGetComponentPathExW(
<MarshalAs(UnmanagedType.LPWStr)> szProductCode As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szComponentCode As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szUserSid As String, ' LPCWSTR optional
dwContext As Integer, ' MSIINSTALLCONTEXT optional
<MarshalAs(UnmanagedType.LPWStr)> lpOutPathBuffer As System.Text.StringBuilder, ' LPWSTR optional, out
pcchOutPathBuffer As IntPtr ' DWORD* optional, in/out
) As Integer
End Function' szProductCode : LPCWSTR
' szComponentCode : LPCWSTR
' szUserSid : LPCWSTR optional
' dwContext : MSIINSTALLCONTEXT optional
' lpOutPathBuffer : LPWSTR optional, out
' pcchOutPathBuffer : DWORD* optional, in/out
Declare PtrSafe Function MsiGetComponentPathExW Lib "msi" ( _
ByVal szProductCode As LongPtr, _
ByVal szComponentCode As LongPtr, _
ByVal szUserSid As LongPtr, _
ByVal dwContext As Long, _
ByVal lpOutPathBuffer As LongPtr, _
ByVal pcchOutPathBuffer 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
MsiGetComponentPathExW = ctypes.windll.msi.MsiGetComponentPathExW
MsiGetComponentPathExW.restype = ctypes.c_int
MsiGetComponentPathExW.argtypes = [
wintypes.LPCWSTR, # szProductCode : LPCWSTR
wintypes.LPCWSTR, # szComponentCode : LPCWSTR
wintypes.LPCWSTR, # szUserSid : LPCWSTR optional
ctypes.c_int, # dwContext : MSIINSTALLCONTEXT optional
wintypes.LPWSTR, # lpOutPathBuffer : LPWSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchOutPathBuffer : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiGetComponentPathExW = Fiddle::Function.new(
lib['MsiGetComponentPathExW'],
[
Fiddle::TYPE_VOIDP, # szProductCode : LPCWSTR
Fiddle::TYPE_VOIDP, # szComponentCode : LPCWSTR
Fiddle::TYPE_VOIDP, # szUserSid : LPCWSTR optional
Fiddle::TYPE_INT, # dwContext : MSIINSTALLCONTEXT optional
Fiddle::TYPE_VOIDP, # lpOutPathBuffer : LPWSTR optional, out
Fiddle::TYPE_VOIDP, # pcchOutPathBuffer : DWORD* optional, in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiGetComponentPathExW(
szProductCode: *const u16, // LPCWSTR
szComponentCode: *const u16, // LPCWSTR
szUserSid: *const u16, // LPCWSTR optional
dwContext: i32, // MSIINSTALLCONTEXT optional
lpOutPathBuffer: *mut u16, // LPWSTR 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.Unicode)]
public static extern int MsiGetComponentPathExW([MarshalAs(UnmanagedType.LPWStr)] string szProductCode, [MarshalAs(UnmanagedType.LPWStr)] string szComponentCode, [MarshalAs(UnmanagedType.LPWStr)] string szUserSid, int dwContext, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpOutPathBuffer, IntPtr pcchOutPathBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetComponentPathExW' -Namespace Win32 -PassThru
# $api::MsiGetComponentPathExW(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer)#uselib "msi.dll"
#func global MsiGetComponentPathExW "MsiGetComponentPathExW" wptr, wptr, wptr, wptr, wptr, wptr
; MsiGetComponentPathExW szProductCode, szComponentCode, szUserSid, dwContext, varptr(lpOutPathBuffer), varptr(pcchOutPathBuffer) ; 戻り値は stat
; szProductCode : LPCWSTR -> "wptr"
; szComponentCode : LPCWSTR -> "wptr"
; szUserSid : LPCWSTR optional -> "wptr"
; dwContext : MSIINSTALLCONTEXT optional -> "wptr"
; lpOutPathBuffer : LPWSTR optional, out -> "wptr"
; pcchOutPathBuffer : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msi.dll" #cfunc global MsiGetComponentPathExW "MsiGetComponentPathExW" wstr, wstr, wstr, int, var, var ; res = MsiGetComponentPathExW(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer) ; szProductCode : LPCWSTR -> "wstr" ; szComponentCode : LPCWSTR -> "wstr" ; szUserSid : LPCWSTR optional -> "wstr" ; dwContext : MSIINSTALLCONTEXT optional -> "int" ; lpOutPathBuffer : LPWSTR optional, out -> "var" ; pcchOutPathBuffer : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiGetComponentPathExW "MsiGetComponentPathExW" wstr, wstr, wstr, int, sptr, sptr ; res = MsiGetComponentPathExW(szProductCode, szComponentCode, szUserSid, dwContext, varptr(lpOutPathBuffer), varptr(pcchOutPathBuffer)) ; szProductCode : LPCWSTR -> "wstr" ; szComponentCode : LPCWSTR -> "wstr" ; szUserSid : LPCWSTR optional -> "wstr" ; dwContext : MSIINSTALLCONTEXT optional -> "int" ; lpOutPathBuffer : LPWSTR optional, out -> "sptr" ; pcchOutPathBuffer : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INSTALLSTATE MsiGetComponentPathExW(LPCWSTR szProductCode, LPCWSTR szComponentCode, LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPWSTR lpOutPathBuffer, DWORD* pcchOutPathBuffer) #uselib "msi.dll" #cfunc global MsiGetComponentPathExW "MsiGetComponentPathExW" wstr, wstr, wstr, int, var, var ; res = MsiGetComponentPathExW(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer) ; szProductCode : LPCWSTR -> "wstr" ; szComponentCode : LPCWSTR -> "wstr" ; szUserSid : LPCWSTR optional -> "wstr" ; dwContext : MSIINSTALLCONTEXT optional -> "int" ; lpOutPathBuffer : LPWSTR optional, out -> "var" ; pcchOutPathBuffer : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INSTALLSTATE MsiGetComponentPathExW(LPCWSTR szProductCode, LPCWSTR szComponentCode, LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPWSTR lpOutPathBuffer, DWORD* pcchOutPathBuffer) #uselib "msi.dll" #cfunc global MsiGetComponentPathExW "MsiGetComponentPathExW" wstr, wstr, wstr, int, intptr, intptr ; res = MsiGetComponentPathExW(szProductCode, szComponentCode, szUserSid, dwContext, varptr(lpOutPathBuffer), varptr(pcchOutPathBuffer)) ; szProductCode : LPCWSTR -> "wstr" ; szComponentCode : LPCWSTR -> "wstr" ; szUserSid : LPCWSTR optional -> "wstr" ; dwContext : MSIINSTALLCONTEXT optional -> "int" ; lpOutPathBuffer : LPWSTR optional, out -> "intptr" ; pcchOutPathBuffer : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiGetComponentPathExW = msi.NewProc("MsiGetComponentPathExW")
)
// szProductCode (LPCWSTR), szComponentCode (LPCWSTR), szUserSid (LPCWSTR optional), dwContext (MSIINSTALLCONTEXT optional), lpOutPathBuffer (LPWSTR optional, out), pcchOutPathBuffer (DWORD* optional, in/out)
r1, _, err := procMsiGetComponentPathExW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProductCode))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szComponentCode))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szUserSid))),
uintptr(dwContext),
uintptr(lpOutPathBuffer),
uintptr(pcchOutPathBuffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INSTALLSTATEfunction MsiGetComponentPathExW(
szProductCode: PWideChar; // LPCWSTR
szComponentCode: PWideChar; // LPCWSTR
szUserSid: PWideChar; // LPCWSTR optional
dwContext: Integer; // MSIINSTALLCONTEXT optional
lpOutPathBuffer: PWideChar; // LPWSTR optional, out
pcchOutPathBuffer: Pointer // DWORD* optional, in/out
): Integer; stdcall;
external 'msi.dll' name 'MsiGetComponentPathExW';result := DllCall("msi\MsiGetComponentPathExW"
, "WStr", szProductCode ; LPCWSTR
, "WStr", szComponentCode ; LPCWSTR
, "WStr", szUserSid ; LPCWSTR optional
, "Int", dwContext ; MSIINSTALLCONTEXT optional
, "Ptr", lpOutPathBuffer ; LPWSTR optional, out
, "Ptr", pcchOutPathBuffer ; DWORD* optional, in/out
, "Int") ; return: INSTALLSTATE●MsiGetComponentPathExW(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer) = DLL("msi.dll", "int MsiGetComponentPathExW(char*, char*, char*, int, char*, void*)")
# 呼び出し: MsiGetComponentPathExW(szProductCode, szComponentCode, szUserSid, dwContext, lpOutPathBuffer, pcchOutPathBuffer)
# szProductCode : LPCWSTR -> "char*"
# szComponentCode : LPCWSTR -> "char*"
# szUserSid : LPCWSTR optional -> "char*"
# dwContext : MSIINSTALLCONTEXT optional -> "int"
# lpOutPathBuffer : LPWSTR optional, out -> "char*"
# pcchOutPathBuffer : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。