【发布时间】:2017-12-08 15:54:38
【问题描述】:
我已使用 Visual Studio 安装项目来创建 MSI。我在 Orca 中编辑了 MSI,以便在首次打开时通过 DLL 执行自定义操作。当我运行 MSI 时,msiexec 会记录以下内容:
MSI (c) (E4:BC) [15:28:14:453]: Doing action: CustomAction1
Action 15:28:14: CustomAction1.
Action start 15:28:14: CustomAction1.
MSI (c) (E4:BC) [15:28:14:453]: Note: 1: 2235 2: 3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'CustomAction1'
MSI (c) (E4:BC) [15:28:14:453]: Creating MSIHANDLE (13) of type 790542 for thread 3260
MSI (c) (E4:B4) [15:28:14:453]: Invoking remote custom action. DLL: C:\DOCUME~1\USERNA~1\LOCALS~1\Temp\MSIA3.tmp, Entrypoint: SampleFunction
MSI (c) (E4:B4) [15:28:14:453]: Closing MSIHANDLE (13) of type 790542 for thread 3260
Action ended 15:28:14: CustomAction1. Return value 3.
MSI (c) (E4:BC) [15:28:14:468]: Doing action: FatalErrorForm
Action 15:28:14: FatalErrorForm.
Action start 15:28:14: FatalErrorForm.
MSI (c) (E4:BC) [15:28:14:468]: Note: 1: 2235 2: 3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'FatalErrorForm'
然后安装程序向导会显示错误消息:The installer was interrupted before MyProduct could be installed. You need to restart the installer to try again.
自定义 DLL 是用 C++ 编写的。以下是源代码:
MyCustomAction.cpp:
// MyCustomAction.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
UINT __stdcall SampleFunction(MSIHANDLE hModule)
{
//This is the function that is called by the MSI
//It is empty because I just want to check that it can be called without interrupting the installer, then I will add the actual functionality
}
MyCustomAction.def:
; MyCustomAction.def
;
; defines the exported functions which will be available to the MSI engine
LIBRARY "MyCustomAction"
DESCRIPTION 'Custom Action DLL'
EXPORTS
SampleFunction
我还在 DLL 的附加依赖项中引用了msi.lib。当我目前没有明确告诉它做任何事情时,为什么自定义操作会中断安装?任何帮助将不胜感激。
更新:
在 Orca 中,自定义操作位于 Binary 表中,并且是 CustomAction 表中的类型 1。自定义操作是 Immediate,在 InstallUISequence 表中发生在 IsolateComponents 之后和 WelcomeForm 之前。
【问题讨论】:
-
你的函数没有返回任何东西; VS 不会产生警告吗?
-
@tkausl 没有警告。它构建成功。
-
那么我猜警告级别不够高。不过,该函数需要返回一些东西。
-
@tkausl 我也成功了
return 1;,但我遇到了同样的问题。 -
是的,因为 MSI 想要
ERROR_SUCCESS。
标签: c++ visual-studio dll windows-installer orca