使用msi API更改安装路径

时间:2015-06-11 07:15:45

标签: c deployment installation windows-installer

我正在尝试使用这些代码行手动设置安装路径

MSIHANDLE msiHandle;
UINT openPackageExitCode = MsiOpenPackage(LR"(path to .msi file)", &msiHandle);
LPCTSTR newPath = LR"(C:\test\)";
UINT changePathResult = MsiSetTargetPath(msiHandle, L"INSTALLDIR", newPath);
MsiCloseHandle(msiHandle);

但是,我收到一条错误,上面写着ERROR_DIRECTORY

如何使用此方法更改安装路径?

1 个答案:

答案 0 :(得分:1)

MsiSetTargetPath操作解决了我的问题后,在自定义操作中调用CostFinalize