diable OS I/O notification on removal of media

  • Thread starter Thread starter Hermit Dave
  • Start date Start date
H

Hermit Dave

Hello All,

I am in process of writing a small winforms control to read and copy data
off a removable drive.
I started it off as a winforms application and then dropped it in favour of
a control.
I have the drive insert event (using WMI) and copy process working using
recursive iteration.
have put in a try catch block within copy process to handle user removing
the media.

instead the system handles the IO read failure prompting me with the
following message and then passes control to my catch block.

Application.exe - Wrong Volume
The wrong volume is in the drive. Please insert volume VOLUME_NAME in drive
DRIVE_LETTER:
with cancel, try again and continue options

what i would like to know is whether there is a way to ensure that the
system doesn't prompt the user instead it is be handled from within the
code.
would be glad for any pointers, thanks in advance
 
Hi Hermit,

Thanks for posting in the community!
From my understanding , you would like to disable the system error message
box and handle the error in your program, If I didn't understand your
problem correctly, please let me know.

You may try using the API SetErrorMode (SEM_FAILCRITICALERRORS), for more
information on this API, please refer to MSDN:
<SetErrorMode>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/
seterrormode.asp

Does it solve your problem?
Please reply to this thread if you have any further questions on it.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
thank you for the prompt reply. i will give it a try in a few minutes and
update the post.

Thanks
 
Yeng-Shen,

Thank you for replying and pointing me to the right api.
SetErrorMode did the job correctly.
My obvious aim was to try and not use direct api calls but this will do for
now.

Thanks once again.

--
Regards,
HD
Once a Geek.... Always a Geek
Hermit Dave said:
thank you for the prompt reply. i will give it a try in a few minutes and
update the post.

Thanks

--
Regards,
HD
Once a Geek.... Always a Geek
"Ying-Shen Yu[MSFT]" said:
Hi Hermit,

Thanks for posting in the community!
From my understanding , you would like to disable the system error
message
box and handle the error in your program, If I didn't understand your
problem correctly, please let me know.

You may try using the API SetErrorMode (SEM_FAILCRITICALERRORS), for more
information on this API, please refer to MSDN:
<SetErrorMode>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/
seterrormode.asp

Does it solve your problem?
Please reply to this thread if you have any further questions on it.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no
rights.
This mail should not be replied directly, "online" should be removed
before
sending.
 
apologies for the mis-spelled name

--
Regards,
HD
Once a Geek.... Always a Geek
Hermit Dave said:
Yeng-Shen,

Thank you for replying and pointing me to the right api.
SetErrorMode did the job correctly.
My obvious aim was to try and not use direct api calls but this will do
for now.

Thanks once again.

--
Regards,
HD
Once a Geek.... Always a Geek
Hermit Dave said:
thank you for the prompt reply. i will give it a try in a few minutes and
update the post.

Thanks

--
Regards,
HD
Once a Geek.... Always a Geek
"Ying-Shen Yu[MSFT]" said:
Hi Hermit,

Thanks for posting in the community!
From my understanding , you would like to disable the system error
message
box and handle the error in your program, If I didn't understand your
problem correctly, please let me know.

You may try using the API SetErrorMode (SEM_FAILCRITICALERRORS), for
more
information on this API, please refer to MSDN:
<SetErrorMode>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/
seterrormode.asp

Does it solve your problem?
Please reply to this thread if you have any further questions on it.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no
rights.
This mail should not be replied directly, "online" should be removed
before
sending.
 
Back
Top