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
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.