ホーム › System.ApplicationInstallationAndServicing › MsiEnumComponentCostsA
MsiEnumComponentCostsA
関数コンポーネントのドライブ別ディスクコストを列挙する(ANSI版)。
シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiEnumComponentCostsA(
MSIHANDLE hInstall,
LPCSTR szComponent,
DWORD dwIndex,
INSTALLSTATE iState,
LPSTR szDriveBuf,
DWORD* pcchDriveBuf,
INT* piCost,
INT* piTempCost
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInstall | MSIHANDLE | in |
| szComponent | LPCSTR | in |
| dwIndex | DWORD | in |
| iState | INSTALLSTATE | in |
| szDriveBuf | LPSTR | out |
| pcchDriveBuf | DWORD* | inout |
| piCost | INT* | out |
| piTempCost | INT* | out |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiEnumComponentCostsA(
MSIHANDLE hInstall,
LPCSTR szComponent,
DWORD dwIndex,
INSTALLSTATE iState,
LPSTR szDriveBuf,
DWORD* pcchDriveBuf,
INT* piCost,
INT* piTempCost
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiEnumComponentCostsA(
uint hInstall, // MSIHANDLE
[MarshalAs(UnmanagedType.LPStr)] string szComponent, // LPCSTR
uint dwIndex, // DWORD
int iState, // INSTALLSTATE
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szDriveBuf, // LPSTR out
ref uint pcchDriveBuf, // DWORD* in/out
out int piCost, // INT* out
out int piTempCost // INT* out
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiEnumComponentCostsA(
hInstall As UInteger, ' MSIHANDLE
<MarshalAs(UnmanagedType.LPStr)> szComponent As String, ' LPCSTR
dwIndex As UInteger, ' DWORD
iState As Integer, ' INSTALLSTATE
<MarshalAs(UnmanagedType.LPStr)> szDriveBuf As System.Text.StringBuilder, ' LPSTR 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 : LPCSTR
' dwIndex : DWORD
' iState : INSTALLSTATE
' szDriveBuf : LPSTR out
' pcchDriveBuf : DWORD* in/out
' piCost : INT* out
' piTempCost : INT* out
Declare PtrSafe Function MsiEnumComponentCostsA Lib "msi" ( _
ByVal hInstall As Long, _
ByVal szComponent As String, _
ByVal dwIndex As Long, _
ByVal iState As Long, _
ByVal szDriveBuf As String, _
ByRef pcchDriveBuf As Long, _
ByRef piCost As Long, _
ByRef piTempCost As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiEnumComponentCostsA = ctypes.windll.msi.MsiEnumComponentCostsA
MsiEnumComponentCostsA.restype = wintypes.DWORD
MsiEnumComponentCostsA.argtypes = [
wintypes.DWORD, # hInstall : MSIHANDLE
wintypes.LPCSTR, # szComponent : LPCSTR
wintypes.DWORD, # dwIndex : DWORD
ctypes.c_int, # iState : INSTALLSTATE
wintypes.LPSTR, # szDriveBuf : LPSTR 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')
MsiEnumComponentCostsA = Fiddle::Function.new(
lib['MsiEnumComponentCostsA'],
[
-Fiddle::TYPE_INT, # hInstall : MSIHANDLE
Fiddle::TYPE_VOIDP, # szComponent : LPCSTR
-Fiddle::TYPE_INT, # dwIndex : DWORD
Fiddle::TYPE_INT, # iState : INSTALLSTATE
Fiddle::TYPE_VOIDP, # szDriveBuf : LPSTR out
Fiddle::TYPE_VOIDP, # pcchDriveBuf : DWORD* in/out
Fiddle::TYPE_VOIDP, # piCost : INT* out
Fiddle::TYPE_VOIDP, # piTempCost : INT* out
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiEnumComponentCostsA(
hInstall: u32, // MSIHANDLE
szComponent: *const u8, // LPCSTR
dwIndex: u32, // DWORD
iState: i32, // INSTALLSTATE
szDriveBuf: *mut u8, // LPSTR 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.Ansi)]
public static extern uint MsiEnumComponentCostsA(uint hInstall, [MarshalAs(UnmanagedType.LPStr)] string szComponent, uint dwIndex, int iState, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szDriveBuf, ref uint pcchDriveBuf, out int piCost, out int piTempCost);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiEnumComponentCostsA' -Namespace Win32 -PassThru
# $api::MsiEnumComponentCostsA(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost)#uselib "msi.dll"
#func global MsiEnumComponentCostsA "MsiEnumComponentCostsA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; MsiEnumComponentCostsA hInstall, szComponent, dwIndex, iState, varptr(szDriveBuf), varptr(pcchDriveBuf), varptr(piCost), varptr(piTempCost) ; 戻り値は stat
; hInstall : MSIHANDLE -> "sptr"
; szComponent : LPCSTR -> "sptr"
; dwIndex : DWORD -> "sptr"
; iState : INSTALLSTATE -> "sptr"
; szDriveBuf : LPSTR out -> "sptr"
; pcchDriveBuf : DWORD* in/out -> "sptr"
; piCost : INT* out -> "sptr"
; piTempCost : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msi.dll" #cfunc global MsiEnumComponentCostsA "MsiEnumComponentCostsA" int, str, int, int, var, var, var, var ; res = MsiEnumComponentCostsA(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost) ; hInstall : MSIHANDLE -> "int" ; szComponent : LPCSTR -> "str" ; dwIndex : DWORD -> "int" ; iState : INSTALLSTATE -> "int" ; szDriveBuf : LPSTR out -> "var" ; pcchDriveBuf : DWORD* in/out -> "var" ; piCost : INT* out -> "var" ; piTempCost : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiEnumComponentCostsA "MsiEnumComponentCostsA" int, str, int, int, sptr, sptr, sptr, sptr ; res = MsiEnumComponentCostsA(hInstall, szComponent, dwIndex, iState, varptr(szDriveBuf), varptr(pcchDriveBuf), varptr(piCost), varptr(piTempCost)) ; hInstall : MSIHANDLE -> "int" ; szComponent : LPCSTR -> "str" ; dwIndex : DWORD -> "int" ; iState : INSTALLSTATE -> "int" ; szDriveBuf : LPSTR out -> "sptr" ; pcchDriveBuf : DWORD* in/out -> "sptr" ; piCost : INT* out -> "sptr" ; piTempCost : INT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD MsiEnumComponentCostsA(MSIHANDLE hInstall, LPCSTR szComponent, DWORD dwIndex, INSTALLSTATE iState, LPSTR szDriveBuf, DWORD* pcchDriveBuf, INT* piCost, INT* piTempCost) #uselib "msi.dll" #cfunc global MsiEnumComponentCostsA "MsiEnumComponentCostsA" int, str, int, int, var, var, var, var ; res = MsiEnumComponentCostsA(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost) ; hInstall : MSIHANDLE -> "int" ; szComponent : LPCSTR -> "str" ; dwIndex : DWORD -> "int" ; iState : INSTALLSTATE -> "int" ; szDriveBuf : LPSTR out -> "var" ; pcchDriveBuf : DWORD* in/out -> "var" ; piCost : INT* out -> "var" ; piTempCost : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MsiEnumComponentCostsA(MSIHANDLE hInstall, LPCSTR szComponent, DWORD dwIndex, INSTALLSTATE iState, LPSTR szDriveBuf, DWORD* pcchDriveBuf, INT* piCost, INT* piTempCost) #uselib "msi.dll" #cfunc global MsiEnumComponentCostsA "MsiEnumComponentCostsA" int, str, int, int, intptr, intptr, intptr, intptr ; res = MsiEnumComponentCostsA(hInstall, szComponent, dwIndex, iState, varptr(szDriveBuf), varptr(pcchDriveBuf), varptr(piCost), varptr(piTempCost)) ; hInstall : MSIHANDLE -> "int" ; szComponent : LPCSTR -> "str" ; dwIndex : DWORD -> "int" ; iState : INSTALLSTATE -> "int" ; szDriveBuf : LPSTR out -> "intptr" ; pcchDriveBuf : DWORD* in/out -> "intptr" ; piCost : INT* out -> "intptr" ; piTempCost : INT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiEnumComponentCostsA = msi.NewProc("MsiEnumComponentCostsA")
)
// hInstall (MSIHANDLE), szComponent (LPCSTR), dwIndex (DWORD), iState (INSTALLSTATE), szDriveBuf (LPSTR out), pcchDriveBuf (DWORD* in/out), piCost (INT* out), piTempCost (INT* out)
r1, _, err := procMsiEnumComponentCostsA.Call(
uintptr(hInstall),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szComponent))),
uintptr(dwIndex),
uintptr(iState),
uintptr(szDriveBuf),
uintptr(pcchDriveBuf),
uintptr(piCost),
uintptr(piTempCost),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiEnumComponentCostsA(
hInstall: DWORD; // MSIHANDLE
szComponent: PAnsiChar; // LPCSTR
dwIndex: DWORD; // DWORD
iState: Integer; // INSTALLSTATE
szDriveBuf: PAnsiChar; // LPSTR out
pcchDriveBuf: Pointer; // DWORD* in/out
piCost: Pointer; // INT* out
piTempCost: Pointer // INT* out
): DWORD; stdcall;
external 'msi.dll' name 'MsiEnumComponentCostsA';result := DllCall("msi\MsiEnumComponentCostsA"
, "UInt", hInstall ; MSIHANDLE
, "AStr", szComponent ; LPCSTR
, "UInt", dwIndex ; DWORD
, "Int", iState ; INSTALLSTATE
, "Ptr", szDriveBuf ; LPSTR out
, "Ptr", pcchDriveBuf ; DWORD* in/out
, "Ptr", piCost ; INT* out
, "Ptr", piTempCost ; INT* out
, "UInt") ; return: DWORD●MsiEnumComponentCostsA(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost) = DLL("msi.dll", "dword MsiEnumComponentCostsA(dword, char*, dword, int, char*, void*, void*, void*)")
# 呼び出し: MsiEnumComponentCostsA(hInstall, szComponent, dwIndex, iState, szDriveBuf, pcchDriveBuf, piCost, piTempCost)
# hInstall : MSIHANDLE -> "dword"
# szComponent : LPCSTR -> "char*"
# dwIndex : DWORD -> "dword"
# iState : INSTALLSTATE -> "int"
# szDriveBuf : LPSTR out -> "char*"
# pcchDriveBuf : DWORD* in/out -> "void*"
# piCost : INT* out -> "void*"
# piTempCost : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。