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