Drive connected event - my hacked approach

  • Thread starter Thread starter Tomppa
  • Start date Start date
T

Tomppa

Win CE 5.0 CF 2.0

I'm wondering if there is a better way to determine if a dive has been
attached or removed from the system.

I ASSUME that all drives follow the following naming convention

\Hard Disk\
\Hard Disk2\
\Hard Disk3\
And so on.

My approach is to use a timer that checks for new or removed drives, say
every 5 seconds or so.
If a drive is connected or removed I raise an event with an enum Connected
or Disconnected and the drive name.

Is there a built in approach to doing this?
 
You can set up to receive notifications. One of those would be a mount
event. The basic scheme can be seen in OpenNETCF.Net.DeviceStatusMonitor
class. That is, it calls RequestDeviceNotifications() call to set up
notifications on a given GUID (or all). Now, the next question is, what is
the right GUID. One to look at might be PMCLASS_BLOCK_DEVICE_GUID.

Also, this thread in the archives:

http://groups.google.com/group/micr...lic.windowsce.*&rnum=1&hl=en#10408e6b6c10a178

Paul T.
 
Thanks Paul,

Hmmm,

I added the follwing pice of code;

OpenNETCF.Net.DeviceStatusMonitor deviceStatusMonitor = new
OpenNETCF.Net.DeviceStatusMonitor(OpenNETCF.Net.DeviceStatusMonitor.FATFS_MOUNT_GUID,true)

deviceStatusMonitor.DeviceNotification += new
OpenNETCF.Net.DeviceNotificationEventHandler(deviceStatusMonitor_DeviceNotification);


And the auto-generated event created was this;


void deviceStatusMonitor_DeviceNotification(object sender,
OpenNETCF.Net.DeviceNotificationArgs e)
{
throw new Exception("The method or operation is not implemented.");
}


I wonder if that means it it not functional yet or I need to code add my own
code to the event raised. I am not at my embedded device right now so I
cannot test.
 
Back
Top