| 1852 | } |
| 1853 | |
| 1854 | bool StartWithShellExecute(const char* targetPath, const char* args, const char* workingDir, const char* env, BfpSpawnFlags flags, BfpSpawnResult* outResult) |
| 1855 | { |
| 1856 | SHELLEXECUTEINFOW shellExecuteInfo = { 0 }; |
| 1857 | shellExecuteInfo.cbSize = sizeof(SHELLEXECUTEINFOW); |
| 1858 | shellExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS; |
| 1859 | if ((flags & BfpSpawnFlag_ErrorDialog) != 0) |
| 1860 | { |
| 1861 | //shellExecuteInfo.hwnd = startInfo.ErrorDialogParentHandle; |
| 1862 | } |
| 1863 | else |
| 1864 | { |
| 1865 | shellExecuteInfo.fMask |= SEE_MASK_FLAG_NO_UI; |
| 1866 | } |
| 1867 | |
| 1868 | if ((flags & BfpSpawnFlag_NoWindow) != 0) |
| 1869 | shellExecuteInfo.nShow = SW_HIDE; |
| 1870 | else |
| 1871 | shellExecuteInfo.nShow = SW_SHOWNORMAL; |
| 1872 | |
| 1873 | UTF16String fileW; |
| 1874 | UTF16String verbW; |
| 1875 | UTF16String argsW; |
| 1876 | UTF16String dirW; |
| 1877 | |
| 1878 | String target = targetPath; |
| 1879 | int barPos = (int)target.IndexOf('|'); |
| 1880 | if (barPos != -1) |
| 1881 | { |
| 1882 | fileW = UTF8Decode(target.Substring(0, barPos)); |
| 1883 | shellExecuteInfo.lpFile = fileW.c_str(); |
| 1884 | |
| 1885 | verbW = UTF8Decode(target.Substring(barPos + 1)); |
| 1886 | shellExecuteInfo.lpVerb = verbW.c_str(); |
| 1887 | } |
| 1888 | else |
| 1889 | { |
| 1890 | fileW = UTF8Decode(target); |
| 1891 | shellExecuteInfo.lpFile = fileW.c_str(); |
| 1892 | } |
| 1893 | |
| 1894 | if ((args != NULL) && (args[0] != 0)) |
| 1895 | { |
| 1896 | argsW = UTF8Decode(args); |
| 1897 | shellExecuteInfo.lpParameters = argsW.c_str(); |
| 1898 | } |
| 1899 | |
| 1900 | if ((workingDir != NULL) && (workingDir[0] != 0)) |
| 1901 | { |
| 1902 | dirW = UTF8Decode(workingDir); |
| 1903 | shellExecuteInfo.lpDirectory = dirW.c_str(); |
| 1904 | } |
| 1905 | |
| 1906 | shellExecuteInfo.fMask |= SEE_MASK_FLAG_DDEWAIT; |
| 1907 | |
| 1908 | |
| 1909 | |
| 1910 | BOOL success = ::ShellExecuteExW(&shellExecuteInfo); |
| 1911 | if (!success) |
no test coverage detected