How to suppress Windows system message
I created an application that copies files from hard drive to floppy drive using the CopyFile () API. In the middle of the copy process for a large file, if the diskette is removed from the disk, then the windows system displays an error message.
I want to suppress this error message that the system appears. I googled and read about the API SetErrorMode () used by many applications to solve similar problems and tried to use it with all 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);
The SetErrorMode () API cannot suppress the error message. Can anyone help me understand why it is not working for my application?
Then I came across the following 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 display error messages. This solution works for my application, but I feel like
and. Wrong programming practice is directly related to the system key? there must be an API that should do this. b. Such code should output UAC when executed on Windows Vista or Windows 7.
Can anyone help with the above problem.
This is not really an answer, but some more information based on my experience. I found that SetErrorMode worked on Windows Vista and Windows 7. It didn't work on Windows XP. XP still pops up error messages for simple ... memory could not be "read" ... crash. This was a killer for my use in unattended distributed processing. The article referenced in the question saved my bacon with a fix.
I am still plagued by the issue of modifying the registry programmatically. For my case, I don't need to worry because SetErrorMode worked in 7 and vista (so far), but if it wasn't, I would just test to check if Windows allowed installing it in virtual storage and give the correct behavior.
source to share