使用ShellExecute函数出错
- C/C++ code
char fName[FILENAME_MAX]; GetModuleFileName(NULL, fName, FILENAME_MAX); *strrchr(fName, '\\') = '\0'; *strrchr(fName, '\\') = '\0'; *strrchr(fName, '\\') = '\0'; strcat(fName, "\\CenterDemo\\Debug\\CenterDemo.exe"); ShellExecute(this->m_hWnd,"open",fName,"","", SW_SHOW );
文件路径什么的都是对的,手动点击那个exe也行,为啥这个启动不起来呢?那个地方不对啊?
[解决办法]
ShellExecute(this->m_hWnd,"open",fName,NULL,NULL, SW_SHOW );
[解决办法]
最后一个参数,建议使用SW_SHOWNORMAL
[解决办法]
你调试一下看看fName的值正确?ShellExecute函数的返回值是什么?
[解决办法]
这要你的路径获取正确用这句就可以了
ShellExecute(NULL,_T("open"),path,NULL,NULL,SW_SHOW);
[解决办法]