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

MsiConfigureFeatureW

関数
機能のインストール状態を構成変更する(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiConfigureFeatureW(
    LPCWSTR szProduct,
    LPCWSTR szFeature,
    INSTALLSTATE eInstallState
);

パラメーター

名前方向
szProductLPCWSTRin
szFeatureLPCWSTRin
eInstallStateINSTALLSTATEin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiConfigureFeatureW(
    LPCWSTR szProduct,
    LPCWSTR szFeature,
    INSTALLSTATE eInstallState
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiConfigureFeatureW(
    [MarshalAs(UnmanagedType.LPWStr)] string szProduct,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szFeature,   // LPCWSTR
    int eInstallState   // INSTALLSTATE
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiConfigureFeatureW(
    <MarshalAs(UnmanagedType.LPWStr)> szProduct As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szFeature As String,   ' LPCWSTR
    eInstallState As Integer   ' INSTALLSTATE
) As UInteger
End Function
' szProduct : LPCWSTR
' szFeature : LPCWSTR
' eInstallState : INSTALLSTATE
Declare PtrSafe Function MsiConfigureFeatureW Lib "msi" ( _
    ByVal szProduct As LongPtr, _
    ByVal szFeature As LongPtr, _
    ByVal eInstallState 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

MsiConfigureFeatureW = ctypes.windll.msi.MsiConfigureFeatureW
MsiConfigureFeatureW.restype = wintypes.DWORD
MsiConfigureFeatureW.argtypes = [
    wintypes.LPCWSTR,  # szProduct : LPCWSTR
    wintypes.LPCWSTR,  # szFeature : LPCWSTR
    ctypes.c_int,  # eInstallState : INSTALLSTATE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiConfigureFeatureW = Fiddle::Function.new(
  lib['MsiConfigureFeatureW'],
  [
    Fiddle::TYPE_VOIDP,  # szProduct : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szFeature : LPCWSTR
    Fiddle::TYPE_INT,  # eInstallState : INSTALLSTATE
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiConfigureFeatureW(
        szProduct: *const u16,  // LPCWSTR
        szFeature: *const u16,  // LPCWSTR
        eInstallState: i32  // INSTALLSTATE
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiConfigureFeatureW([MarshalAs(UnmanagedType.LPWStr)] string szProduct, [MarshalAs(UnmanagedType.LPWStr)] string szFeature, int eInstallState);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiConfigureFeatureW' -Namespace Win32 -PassThru
# $api::MsiConfigureFeatureW(szProduct, szFeature, eInstallState)
#uselib "msi.dll"
#func global MsiConfigureFeatureW "MsiConfigureFeatureW" wptr, wptr, wptr
; MsiConfigureFeatureW szProduct, szFeature, eInstallState   ; 戻り値は stat
; szProduct : LPCWSTR -> "wptr"
; szFeature : LPCWSTR -> "wptr"
; eInstallState : INSTALLSTATE -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiConfigureFeatureW "MsiConfigureFeatureW" wstr, wstr, int
; res = MsiConfigureFeatureW(szProduct, szFeature, eInstallState)
; szProduct : LPCWSTR -> "wstr"
; szFeature : LPCWSTR -> "wstr"
; eInstallState : INSTALLSTATE -> "int"
; DWORD MsiConfigureFeatureW(LPCWSTR szProduct, LPCWSTR szFeature, INSTALLSTATE eInstallState)
#uselib "msi.dll"
#cfunc global MsiConfigureFeatureW "MsiConfigureFeatureW" wstr, wstr, int
; res = MsiConfigureFeatureW(szProduct, szFeature, eInstallState)
; szProduct : LPCWSTR -> "wstr"
; szFeature : LPCWSTR -> "wstr"
; eInstallState : INSTALLSTATE -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiConfigureFeatureW = msi.NewProc("MsiConfigureFeatureW")
)

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