Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ StartWithShellExecuteEx()

unsafe bool System.Diagnostics.Process.StartWithShellExecuteEx ( ProcessStartInfo startInfo)
inlineprivate

Definition at line 2062 of file Process.cs.

2063 {
2064 if (!string.IsNullOrEmpty(startInfo.UserName) || startInfo.Password != null)
2065 {
2067 }
2068 if (startInfo.RedirectStandardInput || startInfo.RedirectStandardOutput || startInfo.RedirectStandardError)
2069 {
2071 }
2072 if (startInfo.StandardInputEncoding != null)
2073 {
2075 }
2076 if (startInfo.StandardErrorEncoding != null)
2077 {
2079 }
2080 if (startInfo.StandardOutputEncoding != null)
2081 {
2083 }
2084 if (startInfo._environmentVariables != null)
2085 {
2087 }
2088 string text = startInfo.BuildArguments();
2089 fixed (char* lpFile = ((startInfo.FileName.Length > 0) ? startInfo.FileName : null))
2090 {
2091 fixed (char* lpVerb = ((startInfo.Verb.Length > 0) ? startInfo.Verb : null))
2092 {
2093 fixed (char* lpParameters = ((text.Length > 0) ? text : null))
2094 {
2095 fixed (char* lpDirectory = ((startInfo.WorkingDirectory.Length > 0) ? startInfo.WorkingDirectory : null))
2096 {
2097 global::Interop.Shell32.SHELLEXECUTEINFO sHELLEXECUTEINFO = default(global::Interop.Shell32.SHELLEXECUTEINFO);
2098 sHELLEXECUTEINFO.cbSize = (uint)sizeof(global::Interop.Shell32.SHELLEXECUTEINFO);
2099 sHELLEXECUTEINFO.lpFile = lpFile;
2100 sHELLEXECUTEINFO.lpVerb = lpVerb;
2101 sHELLEXECUTEINFO.lpParameters = lpParameters;
2102 sHELLEXECUTEINFO.lpDirectory = lpDirectory;
2104 global::Interop.Shell32.SHELLEXECUTEINFO sHELLEXECUTEINFO2 = sHELLEXECUTEINFO;
2105 if (startInfo.ErrorDialog)
2106 {
2107 sHELLEXECUTEINFO2.hwnd = startInfo.ErrorDialogParentHandle;
2108 }
2109 else
2110 {
2112 }
2114 {
2118 _ => 1,
2119 };
2120 ShellExecuteHelper shellExecuteHelper = new ShellExecuteHelper(&sHELLEXECUTEINFO2);
2121 if (!shellExecuteHelper.ShellExecuteOnSTAThread())
2122 {
2123 int num = shellExecuteHelper.ErrorCode;
2124 if (num == 0)
2125 {
2126 num = GetShellError(sHELLEXECUTEINFO2.hInstApp);
2127 }
2128 string text2;
2129 switch (num)
2130 {
2131 case 120:
2132 throw new PlatformNotSupportedException(System.SR.UseShellExecuteNotSupported);
2133 default:
2134 text2 = GetErrorMessage(num);
2135 break;
2136 case 193:
2137 case 216:
2139 break;
2140 }
2141 string errorMessage = text2;
2142 throw CreateExceptionForErrorStartingProcess(errorMessage, num, startInfo.FileName, startInfo.WorkingDirectory);
2143 }
2144 if (sHELLEXECUTEINFO2.hProcess != IntPtr.Zero)
2145 {
2147 return true;
2148 }
2149 }
2150 }
2151 }
2152 }
2153 return false;
2154 }
void SetProcessHandle(SafeProcessHandle processHandle)
Definition Process.cs:1175
int GetShellError(IntPtr error)
Definition Process.cs:2156
static Win32Exception CreateExceptionForErrorStartingProcess(string errorMessage, int errorCode, string fileName, string workingDirectory)
Definition Process.cs:1520
static string GetErrorMessage(int error)
Definition Process.cs:2048
static string StandardOutputEncodingNotAllowed
Definition SR.cs:62
static string InvalidApplication
Definition SR.cs:58
static string CantRedirectStreams
Definition SR.cs:74
static string StandardErrorEncodingNotAllowed
Definition SR.cs:64
static string CantUseEnvVars
Definition SR.cs:116
static string StandardInputEncodingNotAllowed
Definition SR.cs:120
static string CantStartAsUser
Definition SR.cs:114
static string UseShellExecuteNotSupported
Definition SR.cs:118
Definition SR.cs:7

References System.SR.CantRedirectStreams, System.SR.CantStartAsUser, System.SR.CantUseEnvVars, System.Diagnostics.Process.CreateExceptionForErrorStartingProcess(), System.Runtime.Serialization.Dictionary, System.Diagnostics.Process.GetErrorMessage(), System.Diagnostics.Process.GetShellError(), System.SR.InvalidApplication, System.Diagnostics.Process.SetProcessHandle(), System.SR.StandardErrorEncodingNotAllowed, System.SR.StandardInputEncodingNotAllowed, System.SR.StandardOutputEncodingNotAllowed, System.text, System.SR.UseShellExecuteNotSupported, and System.IntPtr.Zero.

Referenced by System.Diagnostics.Process.StartCore().