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

MsiSetPropertyW

関数
実行中のインストールセッションのプロパティ値を設定する。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiSetPropertyW(
    MSIHANDLE hInstall,
    LPCWSTR szName,
    LPCWSTR szValue
);

パラメーター

名前方向
hInstallMSIHANDLEin
szNameLPCWSTRin
szValueLPCWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiSetPropertyW(
    MSIHANDLE hInstall,
    LPCWSTR szName,
    LPCWSTR szValue
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiSetPropertyW(
    uint hInstall,   // MSIHANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string szName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szValue   // LPCWSTR
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiSetPropertyW(
    hInstall As UInteger,   ' MSIHANDLE
    <MarshalAs(UnmanagedType.LPWStr)> szName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szValue As String   ' LPCWSTR
) As UInteger
End Function
' hInstall : MSIHANDLE
' szName : LPCWSTR
' szValue : LPCWSTR
Declare PtrSafe Function MsiSetPropertyW Lib "msi" ( _
    ByVal hInstall As Long, _
    ByVal szName As LongPtr, _
    ByVal szValue 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

MsiSetPropertyW = ctypes.windll.msi.MsiSetPropertyW
MsiSetPropertyW.restype = wintypes.DWORD
MsiSetPropertyW.argtypes = [
    wintypes.DWORD,  # hInstall : MSIHANDLE
    wintypes.LPCWSTR,  # szName : LPCWSTR
    wintypes.LPCWSTR,  # szValue : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiSetPropertyW = msi.NewProc("MsiSetPropertyW")
)

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