Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to suppress windows system message

44 views
Skip to first unread message

Felix Antony

unread,
Sep 10, 2009, 10:19:56 AM9/10/09
to
I have created a application which copies files from hard disk to
Floppy drive using the CopyFile() API.
In the middle of the copy process for a large file, if the floppy is
removed from the drive then windows
system popup's up an error message.

I want to suppress this error message that is popped up by the system.
I googled and read about SetErrorMode() API used
by many applications to solve similar issues and tried using it with
all the possible flag options but it fails. Sample code -

UINT uOldErrorMode = SetErrorMode (SEM_FAILCRITICALERRORS |
SEM_NOGPFAULTERRORBOX);
::CopyFile("C:\text.dat","A:\text.dat", FALSE);
SetErrorMode (uOldErrorMode);

SetErrorMode() API fails to suppress the error message. Can anyone
help me in understanding why is it not working with for my
application?

I then came across the below link : http://support.microsoft.com/kb/128642
which talks about the key

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\ErrorMode

whose value can be set to 0,1 or 2 to suppress or show the error
messages. This solution works for my application but I feel that

a. It is not a good programming practices to access the system key
directly? there should be a API that should do this.
b. Such a code shall fail the UAC when executed on Windows Vista or
Windows 7.

Can anybody please provide some help with the above issue.

Regards,
Felix

Goran

unread,
Sep 11, 2009, 2:42:14 AM9/11/09
to

Perhaps SHFileOperation could help (set FOF_NOERRORUI)?

But why is it so bad to just let the system pop up the message? You
already have a person in front of the machine - who else did yank the
disk out?

Groan.

0 new messages