大网数据广告活动
安装更新与部署

Returning Error Messages from Custom Actions

· 52CE 我爱测

This section describes how to send messages from custom actions that actually perform a part of the installation by calling a dynamic link library or script.

This section describes how to send messages from custom actions that actually perform a part of the installation by calling a dynamic link library or script. Note that Custom Action Type 19 only sends a specified error message, returns failure, and then terminates the installation. Custom Action Type 19 does not perform any part of the installation.

To send an error message from a custom action that uses a dynamic-link library (DLL), have the custom action call MsiProcessMessage. Note that custom actions launched by a DoAction ControlEvent can send messages with the Message method but cannot send a message with MsiProcessMessage. On systems earlier than Windows Server 2003, custom actions launched by a DoAction ControlEvent cannot send messages with MsiProcessMessage or Message method. For more information, see Sending Messages to Windows Installer Using MsiProcessMessage.

To display an error message from within a custom action using a DLL

  1. The custom action should call MsiProcessMessage and pass in the parameters hInstall, eMessageType, and hRecord. The handle to the installation, Custom Action Type 19, may be provided to the custom action as described in Accessing the Current Installer Session from Inside a Custom Action or from MsiOpenProduct or MsiOpenPackage.
  2. The parameter eMessageType should specify one of the message types as listed in MsiProcessMessage.
  3. The hRecord parameter of the MsiProcessMessage function depends upon the message type. See Sending Messages to Windows Installer Using MsiProcessMessage. If the message contains formatted data, enter the message into the Error table using the formatting described in Formatted.

To send an error message from a custom action that uses Scripts, the custom action may call the Message method of the Session object.

To display an error message from within a custom action using script

  1. The custom action should call the Message method of the Session object and pass in the parameters kind and record.
  2. The parameter kind should specify one of the message types listed in the Message method.
  3. The record parameter of the Message method depends upon the message type. If the message contains formatted data, enter the message into the Error table using the formatting described in Formatted.

Custom actions using Executable Files cannot send a message by calling MsiProcessMessage or the Message method because they cannot get a handle to the installation.

Related topics

Custom Action Return Values

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。