打开其他的程序

 1     CString strSqlPath = _T("E:\QQ\Bin\QQScLauncher.exe");
 2 
 3     int nLen = WideCharToMultiByte(CP_ACP, 0, strSqlPath, -1, NULL, 0, NULL, NULL);
 4     if (nLen != 0)
 5     {
 6         char* pResult = new char[nLen];
 7         WideCharToMultiByte(CP_ACP, 0, strSqlPath, -1, pResult, nLen, NULL, NULL);
 8 
 9         UINT ret = WinExec(pResult, SW_SHOW);
10         delete[] pResult;
11         pResult = nullptr;
12         if (ret < 31)
13         {
14             if (ret == ERROR_BAD_FORMAT)
15             {
16                 AfxMessageBox(_T("格式错误"));
17             }
18             else if (ret == ERROR_FILE_NOT_FOUND)
19             {
20                 AfxMessageBox(_T("文件未发现"));
21             }
22             else if (ret == ERROR_PATH_NOT_FOUND)
23             {
24                 AfxMessageBox(_T("文件路径不对"));
25             }
26             else if (ret == 0)
27             {
28                 AfxMessageBox(_T("系统内存不足."));
29             }
30             else
31             {
32                 AfxMessageBox(_T("其它位置错误"));
33             }
34         }
35         
36     }
37     else
38         AfxMessageBox(_T("打开失败"));
原文地址:https://www.cnblogs.com/xslwm/p/7208941.html