Question

I want to write a portable application which resides on a USB. When usb attached to pc, the application automatically starts and it may set entry to registry. I want to remove these entries when USB drive removed from the PC. Is it possible to do this?

I know that I can use autorun on my USB drive to start my application, but is there any way that I inform my application that USB needs to be removed, so it can clear the registry?

I am using C#.

Was it helpful?

Solution

I think you will have to P/Invoke a Win32 API - http://msdn.microsoft.com/en-us/library/aa363480%28VS.85%29.aspx.

That should give you the events you need for when it is being unplugged.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top