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