ホーム › System.ApplicationInstallationAndServicing › MsiSetComponentStateW
MsiSetComponentStateW
関数コンポーネントのインストール状態を設定する(Unicode版)。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiSetComponentStateW(
MSIHANDLE hInstall,
LPCWSTR szComponent,
INSTALLSTATE iState
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInstall | MSIHANDLE | in |
| szComponent | LPCWSTR | in |
| iState | INSTALLSTATE | in |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiSetComponentStateW(
MSIHANDLE hInstall,
LPCWSTR szComponent,
INSTALLSTATE iState
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiSetComponentStateW(
uint hInstall, // MSIHANDLE
[MarshalAs(UnmanagedType.LPWStr)] string szComponent, // LPCWSTR
int iState // INSTALLSTATE
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiSetComponentStateW(
hInstall As UInteger, ' MSIHANDLE
<MarshalAs(UnmanagedType.LPWStr)> szComponent As String, ' LPCWSTR
iState As Integer ' INSTALLSTATE
) As UInteger
End Function' hInstall : MSIHANDLE
' szComponent : LPCWSTR
' iState : INSTALLSTATE
Declare PtrSafe Function MsiSetComponentStateW Lib "msi" ( _
ByVal hInstall As Long, _
ByVal szComponent As LongPtr, _
ByVal iState 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
MsiSetComponentStateW = ctypes.windll.msi.MsiSetComponentStateW
MsiSetComponentStateW.restype = wintypes.DWORD
MsiSetComponentStateW.argtypes = [
wintypes.DWORD, # hInstall : MSIHANDLE
wintypes.LPCWSTR, # szComponent : LPCWSTR
ctypes.c_int, # iState : INSTALLSTATE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiSetComponentStateW = Fiddle::Function.new(
lib['MsiSetComponentStateW'],
[
-Fiddle::TYPE_INT, # hInstall : MSIHANDLE
Fiddle::TYPE_VOIDP, # szComponent : LPCWSTR
Fiddle::TYPE_INT, # iState : INSTALLSTATE
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiSetComponentStateW(
hInstall: u32, // MSIHANDLE
szComponent: *const u16, // LPCWSTR
iState: i32 // INSTALLSTATE
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiSetComponentStateW(uint hInstall, [MarshalAs(UnmanagedType.LPWStr)] string szComponent, int iState);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSetComponentStateW' -Namespace Win32 -PassThru
# $api::MsiSetComponentStateW(hInstall, szComponent, iState)#uselib "msi.dll"
#func global MsiSetComponentStateW "MsiSetComponentStateW" wptr, wptr, wptr
; MsiSetComponentStateW hInstall, szComponent, iState ; 戻り値は stat
; hInstall : MSIHANDLE -> "wptr"
; szComponent : LPCWSTR -> "wptr"
; iState : INSTALLSTATE -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiSetComponentStateW "MsiSetComponentStateW" int, wstr, int
; res = MsiSetComponentStateW(hInstall, szComponent, iState)
; hInstall : MSIHANDLE -> "int"
; szComponent : LPCWSTR -> "wstr"
; iState : INSTALLSTATE -> "int"; DWORD MsiSetComponentStateW(MSIHANDLE hInstall, LPCWSTR szComponent, INSTALLSTATE iState)
#uselib "msi.dll"
#cfunc global MsiSetComponentStateW "MsiSetComponentStateW" int, wstr, int
; res = MsiSetComponentStateW(hInstall, szComponent, iState)
; hInstall : MSIHANDLE -> "int"
; szComponent : LPCWSTR -> "wstr"
; iState : INSTALLSTATE -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiSetComponentStateW = msi.NewProc("MsiSetComponentStateW")
)
// hInstall (MSIHANDLE), szComponent (LPCWSTR), iState (INSTALLSTATE)
r1, _, err := procMsiSetComponentStateW.Call(
uintptr(hInstall),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szComponent))),
uintptr(iState),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiSetComponentStateW(
hInstall: DWORD; // MSIHANDLE
szComponent: PWideChar; // LPCWSTR
iState: Integer // INSTALLSTATE
): DWORD; stdcall;
external 'msi.dll' name 'MsiSetComponentStateW';result := DllCall("msi\MsiSetComponentStateW"
, "UInt", hInstall ; MSIHANDLE
, "WStr", szComponent ; LPCWSTR
, "Int", iState ; INSTALLSTATE
, "UInt") ; return: DWORD●MsiSetComponentStateW(hInstall, szComponent, iState) = DLL("msi.dll", "dword MsiSetComponentStateW(dword, char*, int)")
# 呼び出し: MsiSetComponentStateW(hInstall, szComponent, iState)
# hInstall : MSIHANDLE -> "dword"
# szComponent : LPCWSTR -> "char*"
# iState : INSTALLSTATE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。