一、说明
1、本文的测试环境是win764+vs2013+Qt5.6。
2、使用函数shellExecute调用windows图片浏览器或者IE浏览器打开jpg格式的图片。
3、使用函数shellExecute调用windows office打开word文档。
4、使用该函数注意中文路径的问题( 如有中文路径问题,可以参考我的博客,博客地址:http://blog.csdn.net/toby54king)和函数shellExecute中代码内容的书写格式。
二、测试-文件路径写死
测试通过的方法,文件路径没有写死:
string appPath = QApplication::applicationDirPath().toStdString() + "/pictureFile/testShow.jpg";
int l = MultiByteToWideChar(CP_ACP, 0, appPath.c_str(), -1, NULL, 0);
LPWSTR filePath = new TCHAR[l];
MultiByteToWideChar(CP_ACP, 0, appPath.c_str(), -1, filePath, l);
ShellExecute(NULL, (LPCWSTR)L"open", filePath, (LPCWSTR)L"", (LPCWSTR)L"", SW_SHOW);
//ShellExecute(NULL, (LPCWSTR)L"open", (LPCWSTR)L"E:/Component/Release_Win32/pictureFile/testShow.jpg", (LPCWSTR)L"", (LPCWSTR)L"", SW_SHOW);
//IE浏览器显示图片
//ShellExecute(NULL, (LPCWSTR)L"open", (LPCWSTR)L"iexplore", (LPC