[Lazarus] Recognize a "disk"

Sven Barth svenmauren at vr-web.de
Wed Dec 16 20:01:59 CET 2009


Hello together!

2009/12/16 "ArĂ­ Ricardo Ody" <aro52 at gmx.com8>
> Suppose you connect a Handheld running windows mobile via USB cable to a
> windows machine.
>
>
> Is there a way that I can recognize the new disk added to the system, e.g.,
> determine what of the disks existing in the windows machine is the disk
> added when I connected the handheld?

As far as I know a Windows Mobile device is not recognized as a real 
volume or disk. That directory you see in Windows Explorer is a virtual 
directory which relies on the Remote API (RAPI) to communicate with the 
device and to display/modify its contents.

I also tested the WM_DEVICECHANGE approach: it is not working (as 
expected by me) - but it works well with an SD card...

There are two possibilities you can handle this:
* Try to connect with RAPI to your device. You can call the init 
function with an Event, that will be set once a device shows up (or an 
error happens). You need to use WaitForSingleObject for this.
* Add an entry to "HKLM\Software\Microsoft\Windows CE 
Services\AutoStartOnConnect" which contains an application (Name: 
Something, Value: your application path + parameters), that will be 
started once an ActiveSync connection is established. This application 
can for example notify your main application about this event. There is 
also an AutoStartOnDisconnect key containing applications that will be 
started once a device has been disconnected. (These keys also exist on 
Vista with Windows Mobile Device Center installed)

Note: for working with the file system of a Windows Mobile device you 
ALWAYS need to use RAPI (well... except you "export" the storage card of 
your device with WM5torage).

Regards,
Sven




More information about the Lazarus mailing list