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

MsiEnumComponentCostsW

関数
コンポーネントのドライブ別ディスクコストを列挙する(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiEnumComponentCostsW(
    MSIHANDLE hInstall,
    LPCWSTR szComponent,
    DWORD dwIndex,
    INSTALLSTATE iState,
    LPWSTR szDriveBuf,
    DWORD* pcchDriveBuf,
    INT* piCost,
    INT* piTempCost
);

パラメーター

名前方向
hInstallMSIHANDLEin
szComponentLPCWSTRin
dwIndexDWORDin
iStateINSTALLSTATEin
szDriveBufLPWSTRout
pcchDriveBufDWORD*inout
piCostINT*out
piTempCostINT*out

戻り値の型: DWORD

各言語での呼び出し定義

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiEnumComponentCostsW(
    MSIHANDLE hInstall,
    LPCWSTR szComponent,
    DWORD dwIndex,
    INSTALLSTATE iState,
    LPWSTR szDriveBuf,
    DWORD* pcchDriveBuf,
    INT* piCost,
    INT* piTempCost
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiEnumComponentCostsW(
    uint hInstall,   // MSIHANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string szComponent,   // LPCWSTR
    uint dwIndex,   // DWORD
    int iState,   // INSTALLSTATE
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szDriveBuf,   // LPWSTR out
    ref uint pcchDriveBuf,   // DWORD* in/out
    out int piCost,   // INT* out
    out int piTempCost   // INT* out
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiEnumComponentCostsW(
    hInstall As UInteger,   ' MSIHANDLE
    <MarshalAs(UnmanagedType.LPWStr)> szComponent As String,   ' LPCWSTR
    dwIndex As UInteger,   ' DWORD
    iState As Integer,   ' INSTALLSTATE
    <MarshalAs(UnmanagedType.LPWStr)> szDriveBuf As System.Text.StringBuilder,   ' LPWSTR out
    ByRef pcchDriveBuf As UInteger,   ' DWORD* in/out
    <Out> ByRef piCost As Integer,   ' INT* out
    <Out> ByRef piTempCost As Integer   ' INT* out
) As UInteger
End Function
' hInstall : MSIHANDLE
' szComponent : LPCWSTR
' dwIndex : DWORD
' iState : INSTALLSTATE
' szDriveBuf : LPWSTR out
' pcchDriveBuf : DWORD* in/out
' piCost : INT* out
' piTempCost : INT* out
Declare PtrSafe Function MsiEnumComponentCostsW Lib "msi" ( _
    ByVal hInstall As Long, _
    ByVal szComponent As LongPtr, _
    ByVal dwIndex As Long, _
    ByVal iState As Long, _
    ByVal szDriveBuf As LongPtr, _
    ByRef pcchDriveBuf As Long, _
    ByRef piCost As Long, _
    ByRef piTempCost As Long) 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

MsiEnumComponentCostsW = ctypes.windll.msi.MsiEnumComponentCostsW
MsiEnumComponentCostsW.restype = wintypes.DWORD
MsiEnumComponentCostsW.argtypes = [
    wintypes.DWORD,  # hInstall : MSIHANDLE
    wintypes.LPCWSTR,  # szComponent : LPCWSTR
    wintypes.DWORD,  # dwIndex : DWORD
    ctypes.c_int,  # iState : INSTALLSTATE
    wintypes.LPWSTR,  # szDriveBuf : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # pcchDriveBuf : DWORD* in/out
    ctypes.POINTER(ctypes.c_int),  # piCost : INT* out
    ctypes.POINTER(ctypes.c_int),  # piTempCost : INT* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiEnumComponentCostsW = Fiddle::Function.new(
  lib['MsiEnumComponentCostsW'],
  [
    -Fiddle::TYPE_INT,  # hInstall : MSIHANDLE
    Fiddle::TYPE_VOIDP,  # szComponent : LPCWSTR
    -Fiddle::TYPE_INT,  # dwIndex : DWORD
    Fiddle::TYPE_INT,  # iState : INSTALLSTATE
    Fiddle::TYPE_VOIDP,  # szDriveBuf : LPWSTR out
    Fiddle::TYPE_VOIDP,  # pcchDriveBuf : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # piCost : INT* out
    Fiddle::TYPE_VOIDP,  # piTempCost : INT* out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiEnumComponentCostsW(
        hInstall: u32,  // MSIHANDLE
        szComponent: *const u16,  // LPCWSTR
        dwIndex: u32,  // DWORD
        iState: i32,  // INSTALLSTATE
        szDriveBuf: *mut u16,  // LPWSTR out
        pcchDriveBuf: *mut u32,  // DWORD* in/out
        piCost: *mut i32,  // INT* out
        piTempCost: *mut i32  // INT* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiEnumComponentCostsW(uint hInstall, [MarshalAs(UnmanagedType.LPWStr)] string szComponent, uint dwIndex, int iState, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szDriveBuf, ref uint pcchDriveBuf, out int piCost, out int piTempCost);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiEnumComponentCostsW' -Namespace Win32 -PassThru
# $api::MsiEnumComponentCostsW(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost)
#uselib "msi.dll"
#func global MsiEnumComponentCostsW "MsiEnumComponentCostsW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; MsiEnumComponentCostsW hInstall, szComponent, dwIndex, iState, varptr(szDriveBuf), varptr(pcchDriveBuf), varptr(piCost), varptr(piTempCost)   ; 戻り値は stat
; hInstall : MSIHANDLE -> "wptr"
; szComponent : LPCWSTR -> "wptr"
; dwIndex : DWORD -> "wptr"
; iState : INSTALLSTATE -> "wptr"
; szDriveBuf : LPWSTR out -> "wptr"
; pcchDriveBuf : DWORD* in/out -> "wptr"
; piCost : INT* out -> "wptr"
; piTempCost : INT* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiEnumComponentCostsW "MsiEnumComponentCostsW" int, wstr, int, int, var, var, var, var
; res = MsiEnumComponentCostsW(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost)
; hInstall : MSIHANDLE -> "int"
; szComponent : LPCWSTR -> "wstr"
; dwIndex : DWORD -> "int"
; iState : INSTALLSTATE -> "int"
; szDriveBuf : LPWSTR out -> "var"
; pcchDriveBuf : DWORD* in/out -> "var"
; piCost : INT* out -> "var"
; piTempCost : INT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiEnumComponentCostsW(MSIHANDLE hInstall, LPCWSTR szComponent, DWORD dwIndex, INSTALLSTATE iState, LPWSTR szDriveBuf, DWORD* pcchDriveBuf, INT* piCost, INT* piTempCost)
#uselib "msi.dll"
#cfunc global MsiEnumComponentCostsW "MsiEnumComponentCostsW" int, wstr, int, int, var, var, var, var
; res = MsiEnumComponentCostsW(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost)
; hInstall : MSIHANDLE -> "int"
; szComponent : LPCWSTR -> "wstr"
; dwIndex : DWORD -> "int"
; iState : INSTALLSTATE -> "int"
; szDriveBuf : LPWSTR out -> "var"
; pcchDriveBuf : DWORD* in/out -> "var"
; piCost : INT* out -> "var"
; piTempCost : INT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiEnumComponentCostsW = msi.NewProc("MsiEnumComponentCostsW")
)

// hInstall (MSIHANDLE), szComponent (LPCWSTR), dwIndex (DWORD), iState (INSTALLSTATE), szDriveBuf (LPWSTR out), pcchDriveBuf (DWORD* in/out), piCost (INT* out), piTempCost (INT* out)
r1, _, err := procMsiEnumComponentCostsW.Call(
	uintptr(hInstall),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szComponent))),
	uintptr(dwIndex),
	uintptr(iState),
	uintptr(szDriveBuf),
	uintptr(pcchDriveBuf),
	uintptr(piCost),
	uintptr(piTempCost),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiEnumComponentCostsW(
  hInstall: DWORD;   // MSIHANDLE
  szComponent: PWideChar;   // LPCWSTR
  dwIndex: DWORD;   // DWORD
  iState: Integer;   // INSTALLSTATE
  szDriveBuf: PWideChar;   // LPWSTR out
  pcchDriveBuf: Pointer;   // DWORD* in/out
  piCost: Pointer;   // INT* out
  piTempCost: Pointer   // INT* out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiEnumComponentCostsW';
result := DllCall("msi\MsiEnumComponentCostsW"
    , "UInt", hInstall   ; MSIHANDLE
    , "WStr", szComponent   ; LPCWSTR
    , "UInt", dwIndex   ; DWORD
    , "Int", iState   ; INSTALLSTATE
    , "Ptr", szDriveBuf   ; LPWSTR out
    , "Ptr", pcchDriveBuf   ; DWORD* in/out
    , "Ptr", piCost   ; INT* out
    , "Ptr", piTempCost   ; INT* out
    , "UInt")   ; return: DWORD
●MsiEnumComponentCostsW(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost) = DLL("msi.dll", "dword MsiEnumComponentCostsW(dword, char*, dword, int, char*, void*, void*, void*)")
# 呼び出し: MsiEnumComponentCostsW(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost)
# hInstall : MSIHANDLE -> "dword"
# szComponent : LPCWSTR -> "char*"
# dwIndex : DWORD -> "dword"
# iState : INSTALLSTATE -> "int"
# szDriveBuf : LPWSTR out -> "char*"
# pcchDriveBuf : DWORD* in/out -> "void*"
# piCost : INT* out -> "void*"
# piTempCost : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。