问题描述
大家好,
我有一个奇怪的问题,我希望有人可以帮我解决这个问题。
在以下C ++代码示例中:
Hi all,
I''m having a strange issue and I hope someone could help me on this one.
In the following C++ code sample:
OFLOG_INFO(logger, "Auto open PDF report feature enabled. Launching pdf viewer for file: " + rData.getPDFFileName());
// It is apparently recommended... See MSDN references.
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
SHELLEXECUTEINFO ShExecInfo;
ShExecInfo.cbSize = sizeof(ShExecInfo);
ShExecInfo.fMask = NULL;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = (LPCSTR)"open";
// a small trick to cast from string to LPCSTR
char fileNameCast[MAX_PATH];
sprintf_s(fileNameCast, "\"%s\"", rData.getPDFFileName().c_str());
ShExecInfo.lpFile = (LPCSTR)fileNameCast;
ShExecInfo.lpParameters = NULL;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWDEFAULT;
ShExecInfo.hInstApp = NULL;
if(! ShellExecuteEx(&ShExecInfo))
{
OFLOG_ERROR(logger, "Error during pdf auto-opening. Error Code: " + int(ShExecInfo.hInstApp));
OFLOG_ERROR(logger, GetLastError());
somethingWrong = true;
}
我尝试使用默认的PDF阅读器自动打开PDF文件。
这个代码在我的开发计算机上就像一个魅力,但是一旦我在测试机器上部署我的应用程序,就没有任何反应。 I可以从日志中看到代码执行没有任何错误但只是没有...
我现在正在调试这几天而且我'我很确定我错过了一些愚蠢的东西。我希望有人能看到它。请参阅MSDN参考
注意测试机器安装了pdf阅读器(Adobe Reader)并设置为默认值。在开发和部署机器上运行OS是Windows 7。我还尝试使用更简单的函数完全相同的结果。
先谢谢你的帮助。我真的很感激。
Yass。
I try to automatically open a PDF file with the default PDF reader.
This code works like a charm on my development computer but as soon as I deploy my application on a test machine, nothing happens. I can see from the logs that the code is executed without any error but just nothing...
I''m debugging this for a couple of days now and I''m pretty sure I''m missing something stupid. I hope someone can see it. See MSDN reference here.
Note the test machine has a pdf reader (Adobe Reader) installed and set as default. Running OS is Windows 7 on both development and deployment machine. I also tried with the simpler function ShellExecute with exactly the same result.
Thanks in advance for your help. I really appreciate.
Yass.
推荐答案
这篇关于ShellExecuteEx在部署机器上不执行任何操作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!