-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20091216/1f54ed10/attachment.html>
Mailing lists / lazarus / 2009-12
Recognize a "disk"
10 messages · 7 people ·
- AArí Ricardo Ody 2
- Bbobby 2
- Ccobines 2
- FFelipe Monteiro de Carvalho 1
- HHenry Vermaak 1
- MMatt Shaffer 1
- +1 more
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
I don't know that there's any direct way of finding out the last drive to be added, but if you monitor the drives every 5 seconds or so you can determine which is the newest one to be added (but that won't necessarily mean it's your windows mobile, so I hope you have a way of checking!)
2009/12/16 "Ar? Ricardo Ody"
Show quoted text 24 lines
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20091216/9cf4c4b7/attachment.html>
Hello,
Here you can find code to list all drives in Windows:
http://wiki.freepascal.org/Windows_Programming_Tips#Listing_all_available_drives
I don't know how to get warned when a drive is added, but as said you could periodically check the drives, and probably the drive type can help check if it is a pocketpc or not. I don?t know which type is for pocketpc but a simple test should show this.
bye,
-------------- next part -------------- An HTML attachment was scrubbed... URL:…
2009/12/16 "Ar? Ricardo Ody" :
Show quoted text 8 lines
Google around for examples using the wm_devicechange message. E.g. there is a discussion here:
http://www.codeproject.com/KB/dotnet/devicevolumemonitor.aspx
Henry
Here you can find code to list all drives in Windows:…
2009/12/16 Felipe Monteiro de Carvalho :
I don't know how to get warned when a drive is added, but as said you could periodically check the drives, and probably the drive type can help check if it is a pocketpc or not. I don?t know which type is for pocketpc but a simple test should show this.
Capturing WM_DEVICECHANGE message with wParam=DBT_DEVICEARRIVAL might helpful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20091216/b5aaa862/attachment.html>
2009/12/16 "Ar? Ricardo Ody" :
I have no idea how I can capture the mentioned message. Could you send an example, please?
I have attached a few functions, but it's not complete example. I don't have access to windows right now.
Call SetMyWndProc() with a handle of your main form to hook into message queue and add code to handle WM_DEVICECHANGE in MyWndProc().
Hello together!
2009/12/16 "Ar? Ricardo Ody"
Show quoted text 7 lines
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
-------------- next part -------------- An HTML attachment was scrubbed... URL:…
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20091216/1f28e4be/attachment.html>
Hello together! 2009/12/16 "Ar? Ricardo Ody" As far as I know a Windows Mobile device is…
Sven Barth wrote 46 lines
Hi,
It depends how your device connects to the PC.
I'm developing some little apps for PNA (personal navigation) lately. Some of them will add new drive to the system (most of them will add two new drives, internal flash and external SD card), but some uses ActiveSync to communicate with PC.
I didn't work a lot with the latter one, and for these which are adding new drives to Explorer - there WM_DEVICECHANGE works just fine.
regards
bobby
