MsiSetExternalUIRecord
関数シグネチャ
// msi.dll
#include <windows.h>
DWORD MsiSetExternalUIRecord(
PINSTALLUI_HANDLER_RECORD puiHandler, // optional
DWORD dwMessageFilter,
void* pvContext, // optional
PINSTALLUI_HANDLER_RECORD ppuiPrevHandler // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| puiHandler | PINSTALLUI_HANDLER_RECORD | inoptional | INSTALLUI_HANDLER_RECORD 仕様に準拠するコールバック関数を指定します。 現在の外部 UI ハンドラーを無効にするには、このパラメーターを NULL 値に設定して関数を呼び出します。 | ||||||||||||||||||||||||||||||||||||||
| dwMessageFilter | DWORD | in | 外部メッセージハンドラーを使用して処理するメッセージを指定します。外部ハンドラーが 0 以外の結果を返した場合、そのメッセージは UI に送信されず、代わりにログ記録が有効であればログに記録されます。詳細については、 MsiEnableLog を参照してください。
| ||||||||||||||||||||||||||||||||||||||
| pvContext | void* | inoptional | コールバック関数に渡されるアプリケーションコンテキストへのポインターです。 このパラメーターはエラーチェックに使用できます。 | ||||||||||||||||||||||||||||||||||||||
| ppuiPrevHandler | PINSTALLUI_HANDLER_RECORD | optional | 以前に設定された、INSTALLUI_HANDLER_RECORD 仕様に準拠するコールバック関数へのポインターを返します。コールバックが以前に設定されていない場合は NULL を返します。 |
戻り値の型: DWORD
公式ドキュメント
MsiSetExternalUIRecord 関数は、外部ユーザーインターフェイス (UI) ハンドラーを有効にします。
戻り値
| 戻り値コード | 説明 |
|---|---|
| 関数が正常に完了しました。 | |
|
この値は、カスタムアクションからこの関数を呼び出そうとしたことを示します。
この関数はカスタムアクションから呼び出すことはできません。 |
解説(Remarks)
この関数は Custom Actions から呼び出すことはできません。
MsiSetExternalUIRecord を呼び出して有効にした外部 UI ハンドラーは、Record Object の形式でメッセージを受信します。MsiSetExternalUI を呼び出して有効にした外部 UI ハンドラーは、文字列の形式でメッセージを受信します。外部 UI は常に Windows Installer の内部 UI より前に呼び出されます。レコードベースの外部 UI が有効な場合、文字列ベースの外部 UI よりも前に呼び出されます。レコードベースの外部 UI ハンドラーが 0 (ゼロ) を返した場合、メッセージは有効な文字列ベースの外部 UI ハンドラーに送信されます。外部 UI ハンドラーが 0 以外の値を返した場合、内部の Windows Installer UI ハンドラーは抑制され、メッセージは処理済みとみなされます。
この関数は、設定した外部ユーザーインターフェイスを保存します。現在の外部 UI ハンドラーを以前のハンドラーに置き換えるには、puiHandler パラメーターに INSTALLUI_HANDLER_RECORD を指定し、dwMessageFilter パラメーターに 0 (ゼロ) を指定してこの関数を呼び出します。
puiHandler パラメーターが指す外部ユーザーインターフェイスハンドラーは、dwUILevel パラメーターを INSTALLUILEVEL_NONE に設定して MsiSetInternalUI を呼び出さない限り、外部ユーザーインターフェイスを完全に制御することはできません。 MsiSetInternalUI が呼び出されない場合、内部ユーザーインターフェイスのレベルは既定で INSTALLUILEVEL_BASIC になります。その結果、外部ユーザーインターフェイスハンドラーで処理されなかったメッセージは、Windows Installer によって処理されます。外部ユーザーインターフェイスハンドラーがすべてのメッセージを処理した場合でも、最初の「インストールの準備をしています...」ダイアログは常に表示されます。 MsiSetExternalUI は、 Bootstrapping アプリケーションからのみ呼び出す必要があります。MsiSetExternalUI をカスタムアクションから呼び出すことはできません。
この外部 UI ハンドラーを無効にするには、puiHandler パラメーターに NULL 値を指定して MsiSetExternalUIRecord を呼び出します。
Windows Installer 2.0 および Windows Installer 3.0: サポートされていません。MsiSetExternalUIRecord 関数は Windows Installer 3.1 以降で利用できます。
レコードベースの外部ハンドラーの使用方法の詳細については、Monitoring an Installation Using MsiSetExternalUIRecord を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// msi.dll
#include <windows.h>
DWORD MsiSetExternalUIRecord(
PINSTALLUI_HANDLER_RECORD puiHandler, // optional
DWORD dwMessageFilter,
void* pvContext, // optional
PINSTALLUI_HANDLER_RECORD ppuiPrevHandler // optional
);[DllImport("msi.dll", ExactSpelling = true)]
static extern uint MsiSetExternalUIRecord(
IntPtr puiHandler, // PINSTALLUI_HANDLER_RECORD optional
uint dwMessageFilter, // DWORD
IntPtr pvContext, // void* optional
IntPtr ppuiPrevHandler // PINSTALLUI_HANDLER_RECORD optional
);<DllImport("msi.dll", ExactSpelling:=True)>
Public Shared Function MsiSetExternalUIRecord(
puiHandler As IntPtr, ' PINSTALLUI_HANDLER_RECORD optional
dwMessageFilter As UInteger, ' DWORD
pvContext As IntPtr, ' void* optional
ppuiPrevHandler As IntPtr ' PINSTALLUI_HANDLER_RECORD optional
) As UInteger
End Function' puiHandler : PINSTALLUI_HANDLER_RECORD optional
' dwMessageFilter : DWORD
' pvContext : void* optional
' ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional
Declare PtrSafe Function MsiSetExternalUIRecord Lib "msi" ( _
ByVal puiHandler As LongPtr, _
ByVal dwMessageFilter As Long, _
ByVal pvContext As LongPtr, _
ByVal ppuiPrevHandler As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiSetExternalUIRecord = ctypes.windll.msi.MsiSetExternalUIRecord
MsiSetExternalUIRecord.restype = wintypes.DWORD
MsiSetExternalUIRecord.argtypes = [
ctypes.c_void_p, # puiHandler : PINSTALLUI_HANDLER_RECORD optional
wintypes.DWORD, # dwMessageFilter : DWORD
ctypes.POINTER(None), # pvContext : void* optional
ctypes.c_void_p, # ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiSetExternalUIRecord = Fiddle::Function.new(
lib['MsiSetExternalUIRecord'],
[
Fiddle::TYPE_VOIDP, # puiHandler : PINSTALLUI_HANDLER_RECORD optional
-Fiddle::TYPE_INT, # dwMessageFilter : DWORD
Fiddle::TYPE_VOIDP, # pvContext : void* optional
Fiddle::TYPE_VOIDP, # ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiSetExternalUIRecord(
puiHandler: *const core::ffi::c_void, // PINSTALLUI_HANDLER_RECORD optional
dwMessageFilter: u32, // DWORD
pvContext: *mut (), // void* optional
ppuiPrevHandler: *const core::ffi::c_void // PINSTALLUI_HANDLER_RECORD optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll")]
public static extern uint MsiSetExternalUIRecord(IntPtr puiHandler, uint dwMessageFilter, IntPtr pvContext, IntPtr ppuiPrevHandler);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSetExternalUIRecord' -Namespace Win32 -PassThru
# $api::MsiSetExternalUIRecord(puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler)#uselib "msi.dll"
#func global MsiSetExternalUIRecord "MsiSetExternalUIRecord" sptr, sptr, sptr, sptr
; MsiSetExternalUIRecord puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler ; 戻り値は stat
; puiHandler : PINSTALLUI_HANDLER_RECORD optional -> "sptr"
; dwMessageFilter : DWORD -> "sptr"
; pvContext : void* optional -> "sptr"
; ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiSetExternalUIRecord "MsiSetExternalUIRecord" sptr, int, sptr, sptr
; res = MsiSetExternalUIRecord(puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler)
; puiHandler : PINSTALLUI_HANDLER_RECORD optional -> "sptr"
; dwMessageFilter : DWORD -> "int"
; pvContext : void* optional -> "sptr"
; ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> "sptr"; DWORD MsiSetExternalUIRecord(PINSTALLUI_HANDLER_RECORD puiHandler, DWORD dwMessageFilter, void* pvContext, PINSTALLUI_HANDLER_RECORD ppuiPrevHandler)
#uselib "msi.dll"
#cfunc global MsiSetExternalUIRecord "MsiSetExternalUIRecord" intptr, int, intptr, intptr
; res = MsiSetExternalUIRecord(puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler)
; puiHandler : PINSTALLUI_HANDLER_RECORD optional -> "intptr"
; dwMessageFilter : DWORD -> "int"
; pvContext : void* optional -> "intptr"
; ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiSetExternalUIRecord = msi.NewProc("MsiSetExternalUIRecord")
)
// puiHandler (PINSTALLUI_HANDLER_RECORD optional), dwMessageFilter (DWORD), pvContext (void* optional), ppuiPrevHandler (PINSTALLUI_HANDLER_RECORD optional)
r1, _, err := procMsiSetExternalUIRecord.Call(
uintptr(puiHandler),
uintptr(dwMessageFilter),
uintptr(pvContext),
uintptr(ppuiPrevHandler),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiSetExternalUIRecord(
puiHandler: Pointer; // PINSTALLUI_HANDLER_RECORD optional
dwMessageFilter: DWORD; // DWORD
pvContext: Pointer; // void* optional
ppuiPrevHandler: Pointer // PINSTALLUI_HANDLER_RECORD optional
): DWORD; stdcall;
external 'msi.dll' name 'MsiSetExternalUIRecord';result := DllCall("msi\MsiSetExternalUIRecord"
, "Ptr", puiHandler ; PINSTALLUI_HANDLER_RECORD optional
, "UInt", dwMessageFilter ; DWORD
, "Ptr", pvContext ; void* optional
, "Ptr", ppuiPrevHandler ; PINSTALLUI_HANDLER_RECORD optional
, "UInt") ; return: DWORD●MsiSetExternalUIRecord(puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler) = DLL("msi.dll", "dword MsiSetExternalUIRecord(void*, dword, void*, void*)")
# 呼び出し: MsiSetExternalUIRecord(puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler)
# puiHandler : PINSTALLUI_HANDLER_RECORD optional -> "void*"
# dwMessageFilter : DWORD -> "dword"
# pvContext : void* optional -> "void*"
# ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msi" fn MsiSetExternalUIRecord(
puiHandler: ?*anyopaque, // PINSTALLUI_HANDLER_RECORD optional
dwMessageFilter: u32, // DWORD
pvContext: ?*anyopaque, // void* optional
ppuiPrevHandler: ?*anyopaque // PINSTALLUI_HANDLER_RECORD optional
) callconv(std.os.windows.WINAPI) u32;proc MsiSetExternalUIRecord(
puiHandler: pointer, # PINSTALLUI_HANDLER_RECORD optional
dwMessageFilter: uint32, # DWORD
pvContext: pointer, # void* optional
ppuiPrevHandler: pointer # PINSTALLUI_HANDLER_RECORD optional
): uint32 {.importc: "MsiSetExternalUIRecord", stdcall, dynlib: "msi.dll".}pragma(lib, "msi");
extern(Windows)
uint MsiSetExternalUIRecord(
void* puiHandler, // PINSTALLUI_HANDLER_RECORD optional
uint dwMessageFilter, // DWORD
void* pvContext, // void* optional
void* ppuiPrevHandler // PINSTALLUI_HANDLER_RECORD optional
);ccall((:MsiSetExternalUIRecord, "msi.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler)
# puiHandler : PINSTALLUI_HANDLER_RECORD optional -> Ptr{Cvoid}
# dwMessageFilter : DWORD -> UInt32
# pvContext : void* optional -> Ptr{Cvoid}
# ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiSetExternalUIRecord(
void* puiHandler,
uint32_t dwMessageFilter,
void* pvContext,
void* ppuiPrevHandler);
]]
local msi = ffi.load("msi")
-- msi.MsiSetExternalUIRecord(puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler)
-- puiHandler : PINSTALLUI_HANDLER_RECORD optional
-- dwMessageFilter : DWORD
-- pvContext : void* optional
-- ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiSetExternalUIRecord = lib.func('__stdcall', 'MsiSetExternalUIRecord', 'uint32_t', ['void *', 'uint32_t', 'void *', 'void *']);
// MsiSetExternalUIRecord(puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler)
// puiHandler : PINSTALLUI_HANDLER_RECORD optional -> 'void *'
// dwMessageFilter : DWORD -> 'uint32_t'
// pvContext : void* optional -> 'void *'
// ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("msi.dll", {
MsiSetExternalUIRecord: { parameters: ["pointer", "u32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.MsiSetExternalUIRecord(puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler)
// puiHandler : PINSTALLUI_HANDLER_RECORD optional -> "pointer"
// dwMessageFilter : DWORD -> "u32"
// pvContext : void* optional -> "pointer"
// ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiSetExternalUIRecord(
void* puiHandler,
uint32_t dwMessageFilter,
void* pvContext,
void* ppuiPrevHandler);
C, "msi.dll");
// $ffi->MsiSetExternalUIRecord(puiHandler, dwMessageFilter, pvContext, ppuiPrevHandler);
// puiHandler : PINSTALLUI_HANDLER_RECORD optional
// dwMessageFilter : DWORD
// pvContext : void* optional
// ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Msi extends StdCallLibrary {
Msi INSTANCE = Native.load("msi", Msi.class);
int MsiSetExternalUIRecord(
Callback puiHandler, // PINSTALLUI_HANDLER_RECORD optional
int dwMessageFilter, // DWORD
Pointer pvContext, // void* optional
Callback ppuiPrevHandler // PINSTALLUI_HANDLER_RECORD optional
);
}@[Link("msi")]
lib Libmsi
fun MsiSetExternalUIRecord = MsiSetExternalUIRecord(
puiHandler : Void*, # PINSTALLUI_HANDLER_RECORD optional
dwMessageFilter : UInt32, # DWORD
pvContext : Void*, # void* optional
ppuiPrevHandler : Void* # PINSTALLUI_HANDLER_RECORD optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiSetExternalUIRecordNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Void>, Pointer<Void>);
typedef MsiSetExternalUIRecordDart = int Function(Pointer<Void>, int, Pointer<Void>, Pointer<Void>);
final MsiSetExternalUIRecord = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiSetExternalUIRecordNative, MsiSetExternalUIRecordDart>('MsiSetExternalUIRecord');
// puiHandler : PINSTALLUI_HANDLER_RECORD optional -> Pointer<Void>
// dwMessageFilter : DWORD -> Uint32
// pvContext : void* optional -> Pointer<Void>
// ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiSetExternalUIRecord(
puiHandler: Pointer; // PINSTALLUI_HANDLER_RECORD optional
dwMessageFilter: DWORD; // DWORD
pvContext: Pointer; // void* optional
ppuiPrevHandler: Pointer // PINSTALLUI_HANDLER_RECORD optional
): DWORD; stdcall;
external 'msi.dll' name 'MsiSetExternalUIRecord';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiSetExternalUIRecord"
c_MsiSetExternalUIRecord :: Ptr () -> Word32 -> Ptr () -> Ptr () -> IO Word32
-- puiHandler : PINSTALLUI_HANDLER_RECORD optional -> Ptr ()
-- dwMessageFilter : DWORD -> Word32
-- pvContext : void* optional -> Ptr ()
-- ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msisetexternaluirecord =
foreign "MsiSetExternalUIRecord"
((ptr void) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* puiHandler : PINSTALLUI_HANDLER_RECORD optional -> (ptr void) *)
(* dwMessageFilter : DWORD -> uint32_t *)
(* pvContext : void* optional -> (ptr void) *)
(* ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)
(cffi:defcfun ("MsiSetExternalUIRecord" msi-set-external-uirecord :convention :stdcall) :uint32
(pui-handler :pointer) ; PINSTALLUI_HANDLER_RECORD optional
(dw-message-filter :uint32) ; DWORD
(pv-context :pointer) ; void* optional
(ppui-prev-handler :pointer)) ; PINSTALLUI_HANDLER_RECORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiSetExternalUIRecord = Win32::API::More->new('msi',
'DWORD MsiSetExternalUIRecord(LPVOID puiHandler, DWORD dwMessageFilter, LPVOID pvContext, LPVOID ppuiPrevHandler)');
# my $ret = $MsiSetExternalUIRecord->Call($puiHandler, $dwMessageFilter, $pvContext, $ppuiPrevHandler);
# puiHandler : PINSTALLUI_HANDLER_RECORD optional -> LPVOID
# dwMessageFilter : DWORD -> DWORD
# pvContext : void* optional -> LPVOID
# ppuiPrevHandler : PINSTALLUI_HANDLER_RECORD optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。