在 C++ 中设置项目自定义操作“[TARGETDIR]”
我正在尝试将文件复制到安装目标目录中。
我正在使用这个:
TCHAR destPath[ MAX_PATH ] = &L"[TARGETDIR]";
wcscat_s(destPath, L"[email protected]\\Capture.png");
CopyFile(L"C:\\Users\\waldek\\Desktop\\Capture.png", destPath, 0);
如果我使用这个:
CopyFile(L"C:\\Users\\waldek\\Desktop\\Capture.png", L"C:\\Program Files (x86)\\Microsoft\\Setup1\\[email protected]\\Capture.png", 0);
它可以工作,这基本上就是 destPath 应该评估的内容,我可以看到它在我使用 PMSIHANDLE 时进行评估,它会提醒正确的路径...
我如何强制 CopyFile 评估“[目标目录]";
I am trying to copy file into the setup target directory.
I am using this:
TCHAR destPath[ MAX_PATH ] = &L"[TARGETDIR]";
wcscat_s(destPath, L"[email protected]\\Capture.png");
CopyFile(L"C:\\Users\\waldek\\Desktop\\Capture.png", destPath, 0);
if I use this:
CopyFile(L"C:\\Users\\waldek\\Desktop\\Capture.png", L"C:\\Program Files (x86)\\Microsoft\\Setup1\\[email protected]\\Capture.png", 0);
it works, which is basically what destPath should evaluate to, I can see that it evaluates when I use PMSIHANDLE, it alerts the correct path...
How do I force CopyFile to evalue "[TARGETDIR]";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在属性 CustomactionData 中的安装自定义操作中,我只是将 [TARGETDIR]
vbuff 放在目标目录中,
然后当然是按预期执行串联和 FileCopy...
这对我有用...但我仍然想知道为什么,它没有出现在我发布的原始问题中,最奇怪的是 PMSIHANDLE 写出了正确的路径,但我猜想在 FileCopy 函数中传递它时缺少“翻译”步骤......
我确信我错过了关于这一点的一些理论。
in the Install Custom Action in property CustomactionData, I just put [TARGETDIR]
vbuff is the target directory
then of course the concatenation and the FileCopy executed as expected...
this worked for me... but I still would like to know why, it didn't in the original question I posted, the strangest thing was that the PMSIHANDLE wrote out the correct path, but I guess there "translation" step was missing in passing it in the FileCopy function...
I am sure I am missing some theory on this.
假设这是自定义操作的一部分,您可以使用 MsiFormatRecord。省略了错误处理,它看起来像这样:
Assuming this is part of a custom action, you can use MsiFormatRecord. Error handling omitted, it would look something like this: