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