Skip to content

Commit 329f035

Browse files
Copilotadamsitnik
andauthored
Preserve ERROR_NO_ASSOCIATION NativeErrorCode and clarify resource strings
Co-authored-by: adamsitnik <[email protected]>
1 parent 97ee087 commit 329f035

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/libraries/System.Diagnostics.Process/src/Microsoft/Win32/SafeHandles/SafeProcessHandle.Unix.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ private static SafeProcessHandle StartWithShellExecute(ProcessStartInfo startInf
374374
if (verb != string.Empty &&
375375
!string.Equals(verb, "open", StringComparison.OrdinalIgnoreCase))
376376
{
377-
throw new Win32Exception(SR.Format(SR.UseShellExecuteVerbNotSupported, verb));
377+
throw new Win32Exception(Interop.Errors.ERROR_NO_ASSOCIATION, SR.Format(SR.UseShellExecuteVerbNotSupported, verb));
378378
}
379379

380380
// On Windows, UseShellExecute of executables and scripts causes those files to be executed.
@@ -405,7 +405,7 @@ private static SafeProcessHandle StartWithShellExecute(ProcessStartInfo startInf
405405
}
406406

407407
// use default program to open file/url
408-
filename = Process.GetPathToOpenFile() ?? throw new Win32Exception(SR.UseShellExecuteNoOpenProgram);
408+
filename = Process.GetPathToOpenFile() ?? throw new Win32Exception(Interop.Errors.ERROR_NO_ASSOCIATION, SR.UseShellExecuteNoOpenProgram);
409409
string[] openFileArgv = ProcessUtils.ParseArgv(startInfo, filename, ignoreArguments: true);
410410

411411
SafeProcessHandle result = ForkAndExecProcess(

‎src/libraries/System.Diagnostics.Process/src/Resources/Strings.resx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@
391391
<value>The callback must return a positive process ID for the newly created process.</value>
392392
</data>
393393
<data name="UseShellExecuteVerbNotSupported" xml:space="preserve">
394-
<value>The verb '{0}' is not supported for UseShellExecute on this platform. Only the default verb is supported.</value>
394+
<value>The verb '{0}' is not supported for UseShellExecute on this platform. Only the default verb (an empty string or "open") is supported.</value>
395395
</data>
396396
<data name="UseShellExecuteNoOpenProgram" xml:space="preserve">
397-
<value>No application is associated with the specified file for UseShellExecute on this platform.</value>
397+
<value>No application is associated with the specified file or URL for UseShellExecute on this platform.</value>
398398
</data>
399399
</root>

0 commit comments

Comments
 (0)