Click here to Skip to main content
15,881,139 members
Home / Discussions / C#
   

C#

 
GeneralRe: Serial port listening application Pin
Pete O'Hanlon16-Mar-23 0:19
mvePete O'Hanlon16-Mar-23 0:19 
GeneralRe: Serial port listening application Pin
OriginalGriff16-Mar-23 1:17
mveOriginalGriff16-Mar-23 1:17 
GeneralRe: Serial port listening application Pin
Pete O'Hanlon16-Mar-23 6:11
mvePete O'Hanlon16-Mar-23 6:11 
GeneralRe: Serial port listening application Pin
Dave Kreskowiak16-Mar-23 6:21
mveDave Kreskowiak16-Mar-23 6:21 
QuestionDownloading & Executing an Installer - User Cancels Pin
Kevin Marois13-Mar-23 12:52
professionalKevin Marois13-Mar-23 12:52 
AnswerRe: Downloading & Executing an Installer - User Cancels Pin
Dave Kreskowiak13-Mar-23 17:43
mveDave Kreskowiak13-Mar-23 17:43 
AnswerRe: Downloading & Executing an Installer - User Cancels Pin
Graeme_Grant14-Mar-23 5:39
mvaGraeme_Grant14-Mar-23 5:39 
AnswerRe: Downloading & Executing an Installer - User Cancels Pin
Alan N14-Mar-23 10:00
Alan N14-Mar-23 10:00 
Win32Exception has a NativeErrorCode property which should return 1223 (0x4C7) when the user stops a process starting at a UAC prompt.

An example from my own code where I do something similar is probably clearer than more words!

C#
private static void RestartWithRunAs(ProcessStartInfo psi) {
  psi.UseShellExecute = true;
  psi.ErrorDialog = true;
  psi.Verb = "runas";
  try {
    Process.Start(psi);
  } catch (System.ComponentModel.Win32Exception exc) {
    // Accept cancelled by user as a valid action
    const Int32 CancelledByUser = 1223;
    if (exc.NativeErrorCode != CancelledByUser) {
      // MessageBox.Show(exc.ToString(), "Restart failure");
      throw;
    }
  }
}


See also
System Error Codes (1000-1299) (WinError.h) - Win32 apps | Microsoft Learn[^]
Alan.
GeneralRe: Downloading & Executing an Installer - User Cancels Pin
Kevin Marois14-Mar-23 11:15
professionalKevin Marois14-Mar-23 11:15 
QuestionLooking to hire a programmer Pin
Thomas Matson10-Mar-23 6:33
Thomas Matson10-Mar-23 6:33 
AnswerRe: Looking to hire a programmer Pin
OriginalGriff10-Mar-23 6:34
mveOriginalGriff10-Mar-23 6:34 
GeneralRe: Looking to hire a programmer Pin
Thomas Matson10-Mar-23 6:46
Thomas Matson10-Mar-23 6:46 
GeneralRe: Looking to hire a programmer Pin
Graeme_Grant14-Mar-23 5:20
mvaGraeme_Grant14-Mar-23 5:20 
GeneralOff topic: New icon in Reply - View Thread line in messages Pin
jsc4213-Mar-23 23:16
professionaljsc4213-Mar-23 23:16 
GeneralRe: Off topic: New icon in Reply - View Thread line in messages Pin
OriginalGriff14-Mar-23 0:15
mveOriginalGriff14-Mar-23 0:15 
GeneralRe: Off topic: New icon in Reply - View Thread line in messages Pin
jsc4214-Mar-23 4:00
professionaljsc4214-Mar-23 4:00 
AnswerRe: Looking to hire a programmer Pin
jschell10-Mar-23 11:05
jschell10-Mar-23 11:05 
GeneralRe: Looking to hire a programmer Pin
Thomas Matson10-Mar-23 11:58
Thomas Matson10-Mar-23 11:58 
GeneralRe: Looking to hire a programmer Pin
jschell13-Mar-23 6:21
jschell13-Mar-23 6:21 
GeneralRe: Looking to hire a programmer Pin
Thomas Matson10-Mar-23 11:57
Thomas Matson10-Mar-23 11:57 
AnswerRe: Looking to hire a programmer Pin
Gerry Schmitz13-Mar-23 7:32
mveGerry Schmitz13-Mar-23 7:32 
QuestionLooking for programmers for 8Bit Music Studio in C# (.Net) Pin
kiri0086-Mar-23 21:56
kiri0086-Mar-23 21:56 
AnswerRe: Looking for programmers for 8Bit Music Studio in C# (.Net) Pin
Richard MacCutchan6-Mar-23 22:10
mveRichard MacCutchan6-Mar-23 22:10 
AnswerRe: Looking for programmers for 8Bit Music Studio in C# (.Net) Pin
OriginalGriff6-Mar-23 22:25
mveOriginalGriff6-Mar-23 22:25 
AnswerRe: Looking for programmers for 8Bit Music Studio in C# (.Net) Pin
Gerry Schmitz7-Mar-23 6:03
mveGerry Schmitz7-Mar-23 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.