views:

10

answers:

2

Windows XP shows my Windows Mobile 6 phone (HP iPAQ 514) as "Mobile Device" in "My computer". Using Windows explorer, I can copy files from/to the device and its storage card.

Which possibilities are there to access these files programmatically? Any way to access them using normal filenames or special paths?

Note that I'm searching for a solution that works with the phone connected via USB, not via Bluetooth/Wi-Fi. Question is tagged Python, but I'd like to hear any working solution.

A: 

The "special paths" you're looking for exist at Shell level, not the kernel. Therefore, you shouldn't be using paths from the Win32 kernel namespace (which you linked to), but PIDL 's

MSalters
Does that mean I could get the path using `shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_xxx)`? If so, how can I find the correct CSIDL? Inspecting a shortcut (.lnk) file to the "Mobile Device" didn't give me any hints. In the registry there's a "CLSID" entry for "Mobile Device", but I don't know how to resolve that GUID to a path.
AndiDog
Eh, no - if only because there's only one folder for a CSIDL and you could have multiple Mobile Devices. A `PIDL` is not at all equal to a `CSIDL_xxx` value.
MSalters
Okay, now I found the PIDL of "Mobile Device" with `SHBrowseForFolder` in Python, it's a list of two strings (the first is the PIDL of "My Computer" a.k.a. CSIDL_DRIVES, and the second one is "Mobile Device" I guess). But when I call `SHGetPathFromIDList` on that combined PIDL, I get an error tuple saying "Unspecified error"... Any way to get this working without RAPI?
AndiDog
Sounds right - a PIDL is a _generalized_ path, and the second component should uniquely identify your mobile device instance. `SHGetPathFromIDList` will convert PIDLs to paths in the conventional file system, assuming of course that the PIDL pointed into the conventional file system in the first place, see the "Remarks" section. Yours doesn't.
MSalters
That makes sense. I'll try to use the RAPI for my purposes. Thanks for your help.
AndiDog
A: 

To answer the question how you actually do the reading, you'd be looking at the "RAPI" component of Windows - it's an interface within ActiveSync or Vista's MDM. RAPI offers the COM interfaces IRAPIDevice and IRAPISession; the latter has a lot of familiar Win32 functions. E.g. You get IRAPISession::CeCreateFile which resembles the familiar CreateFile

MSalters
Thanks, pywin32 seems to have an example of copying a file from a device. Please take a look at the other comment - any better solutions apart from RAPI?
AndiDog