C# – Storage Card Problem In windows mobile

ccompact-frameworknetwindows-mobile

I m making windows mobile application, it refers some DLL's but i have some problem here.
Imagine my application is installed in storage card related DLL's present in Storage card only,
if i launch application it refers some of DLL, now i will remove the storage card, still my application will be running,it will not quit only ultimately it leads to restart of my mobile device..
i do get the divice card remove notification but its in DLL and its c++ code.. if card is removed no DLL will be present in storage card, i dont even get the notification also in c# i dont no how to get the card removed notification in c#. how to handle these scenarios please let me know.

Thanks

Best Answer

You can use the function SHChangeNotifyRegister to WM_FILECHANGEINFO message.

After you subscribe, you will be receiving events with ids such as SHCNE_DRIVEREMOVED or SHCNE_MEDIAREMOVED, so you can trigger some actions when storage card is removed.

To use native functions from the compact framework, use P/Invoke.