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

MsiDatabaseApplyTransformW

関数
データベースにトランスフォームを適用して変更を反映する。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiDatabaseApplyTransformW(
    MSIHANDLE hDatabase,
    LPCWSTR szTransformFile,
    MSITRANSFORM_ERROR iErrorConditions
);

パラメーター

名前方向
hDatabaseMSIHANDLEin
szTransformFileLPCWSTRin
iErrorConditionsMSITRANSFORM_ERRORin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

MsiDatabaseApplyTransformW = ctypes.windll.msi.MsiDatabaseApplyTransformW
MsiDatabaseApplyTransformW.restype = wintypes.DWORD
MsiDatabaseApplyTransformW.argtypes = [
    wintypes.DWORD,  # hDatabase : MSIHANDLE
    wintypes.LPCWSTR,  # szTransformFile : LPCWSTR
    ctypes.c_int,  # iErrorConditions : MSITRANSFORM_ERROR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiDatabaseApplyTransformW = msi.NewProc("MsiDatabaseApplyTransformW")
)

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