Click here to Skip to main content
15,893,487 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Style / customize the .NET Treeview Control (vertical spaces between nodes) Pin
Christian Graus24-Mar-07 8:06
protectorChristian Graus24-Mar-07 8:06 
QuestionRe: Style / customize the .NET Treeview Control (vertical spaces between nodes) [modified] Pin
jnkurz025-Mar-07 1:32
jnkurz025-Mar-07 1:32 
QuestionNeed help with forms Pin
thesad24-Mar-07 1:01
thesad24-Mar-07 1:01 
AnswerRe: Need help with forms Pin
Christian Graus24-Mar-07 7:59
protectorChristian Graus24-Mar-07 7:59 
GeneralRe: Need help with forms Pin
thesad24-Mar-07 8:45
thesad24-Mar-07 8:45 
GeneralRe: Need help with forms Pin
Christian Graus24-Mar-07 13:19
protectorChristian Graus24-Mar-07 13:19 
Question.NET-BroadcastEventWindow - No Disk Pin
gmarian23-Mar-07 19:32
gmarian23-Mar-07 19:32 
AnswerRe: .NET-BroadcastEventWindow - No Disk Pin
Luc Pattyn24-Mar-07 2:20
sitebuilderLuc Pattyn24-Mar-07 2:20 
Hi,

in my Explorer replacement, I used the native function SetErrorMode to avoid
the low-level error reporting taht occurs by default on empty drives.
It works on all .NET versions (tested on XP only).

This is part of my code:

// avoid dialog boxes with "There is no disk in the drive" !
using (new LP_SetErrorMode(ErrorModes.FailCriticalErrors)) {
    // do whatever needs to be done
    // when leaving the using block, the ErrorMode is returned
    // to its original value automatically
}


using System;
using System.Runtime.InteropServices;	// DllImport, MarschalAs

namespace LP_Core {
	/// <summary>
	/// Possible mode flags for LP_SetErrorMode constructor.
	/// </summary>
	[Flags]
	public enum ErrorModes {
		/// <summary>
		/// Use the system default, which is to display all error dialog boxes
		/// </summary>
		Default=0x0,
		/// <summary>
		/// The system does not display the critical-error-handler message box.
		/// Instead, the system sends the error to the calling process.
		/// </summary>
		FailCriticalErrors=0x1,
		/// <summary>
		/// 64-bit Windows:  The system automatically fixes memory alignment faults
		/// and makes them invisible to the application. It does this for the
		/// calling process and any descendant processes.
		/// </summary>
		NoOpFaultErrorBox=0x2,
		/// <summary>
		/// The system does not display the general-protection-fault message box.
		/// This flag should only be set by debugging applications that handle
		/// general protection (GP) faults themselves with an exception handler.
		/// </summary>
		NoAlignmentFaultExcept=0x4,
		/// <summary>
		/// The system does not display a message box when it fails to find a file.
		/// Instead, the error is returned to the calling process.
		/// </summary>
		NoOpenFileErrorBox=0x8000
	}
	/// <summary>
	/// LP_SetErrorMode temporarily changes the Windows error mode.
	/// It can be used to try and get a file list on removable media drives
	/// (in order to avoid the dialog box "There is no disk in the drive")
	/// </summary>
	public struct LP_SetErrorMode : IDisposable {
		private int oldErrorMode;

		/// <summary>
		/// Create an instance of LP_SetErrorMode to change the Windows error mode.
		/// </summary>
		/// <remarks>With a using statement, the original value will be restored when the
		/// instance is automatically disposed.</remarks>
		/// <param name="mode"></param>
		public LP_SetErrorMode(ErrorModes mode) {
			oldErrorMode=SetErrorMode((int)mode);	// FailCriticalErrors
		}

		void IDisposable.Dispose() {
			SetErrorMode(oldErrorMode);
		}

		[DllImport("kernel32.dll")]
			private static extern int SetErrorMode(int mode);
	}
}


Hope this helps.





Luc Pattyn

[My Articles]

GeneralRe: .NET-BroadcastEventWindow - No Disk Pin
gmarian24-Mar-07 3:07
gmarian24-Mar-07 3:07 
Question.NET cannot find mfc42.lib?? Pin
Wheatbread22-Mar-07 11:35
Wheatbread22-Mar-07 11:35 
AnswerRe: .NET cannot find mfc42.lib?? Pin
Wheatbread22-Mar-07 12:54
Wheatbread22-Mar-07 12:54 
QuestionPorting VS60 projects to .NET 2003 Pin
Wheatbread22-Mar-07 10:07
Wheatbread22-Mar-07 10:07 
AnswerRe: Porting VS60 projects to .NET 2003 Pin
Christian Graus22-Mar-07 10:21
protectorChristian Graus22-Mar-07 10:21 
AnswerRe: Porting VS60 projects to .NET 2003 Pin
Wheatbread22-Mar-07 10:27
Wheatbread22-Mar-07 10:27 
GeneralRe: Porting VS60 projects to .NET 2003 Pin
Dave Kreskowiak22-Mar-07 15:53
mveDave Kreskowiak22-Mar-07 15:53 
GeneralRe: Porting VS60 projects to .NET 2003 Pin
Kevin McFarlane25-Mar-07 3:00
Kevin McFarlane25-Mar-07 3:00 
AnswerRe: Porting VS60 projects to .NET 2003 Pin
Kevin McFarlane25-Mar-07 3:04
Kevin McFarlane25-Mar-07 3:04 
Questionhow to solve the problem occured due to using setupapi.h and Dbt.h header files in my windows service application.. in windows XP and VC++.Net 2005 Pin
anumadhu21-Mar-07 21:31
anumadhu21-Mar-07 21:31 
AnswerRe: how to solve the problem occured due to using setupapi.h and Dbt.h header files in my windows service application.. in windows XP and VC++.Net 2005 Pin
Adadurov22-Mar-07 5:57
Adadurov22-Mar-07 5:57 
AnswerRe: how to solve the problem occured due to using setupapi.h and Dbt.h header files in my windows service application.. in windows XP and VC++.Net 2005 Pin
Dave Kreskowiak22-Mar-07 6:50
mveDave Kreskowiak22-Mar-07 6:50 
QuestionFrames in HTML Pin
R.S Reddy21-Mar-07 18:48
R.S Reddy21-Mar-07 18:48 
AnswerRe: Frames in HTML Pin
KaineDunno21-Mar-07 22:01
KaineDunno21-Mar-07 22:01 
GeneralRe: Frames in HTML Pin
R.S Reddy21-Mar-07 22:30
R.S Reddy21-Mar-07 22:30 
QuestionPropertyGrid and Image Pin
Alan Seedhouse21-Mar-07 1:34
professionalAlan Seedhouse21-Mar-07 1:34 
Question.NET Logging & Exception Handling Guidelines Pin
K.P.Kannan21-Mar-07 1:24
K.P.Kannan21-Mar-07 1:24 

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.