views:

25

answers:

1

What's the best way to support WindowsMobile5 (and later) devices while maintaining code compatibility with PocketPC 2003, written in C#? We've got a rather large app in use by a bunch of different customers, roughly split equally between people with actual PPC2003 devices, and the rest newer WinMobile5 or newer -- ie, we have to continue supporting the older devices for quite a while yet. Now, I need to add camera-control to the app, at least for those devices that have a camera, so they can snap a photo and attach it to other data that eventually gets sent up to a webservice for processing.

My research so far has turned up the CameraCaptureDialog class in the Microsoft.WindowsMobile.Forms dll, but I can't add that reference to a PocketPC 2003 application. The boss isn't too keen on splitting the application up into seperate PPC2003 and WinMobile projects. Is there a way to load that dll dynamically, and using CameraCaptureDialog that way? Some other option?

A: 

The only way to access the camera at all from a .NetCF PocketPC 2003 application is by P/Invoking a C/C++ DLL. There's a sample app for this floating around the Intertubes somewhere (I'll look for it - I can't remember the details but I think the C code accesses the camera through DirectShow), but it's fairly complicated to work with and probably won't do exactly what you need. On the plus side, if you can figure out how to do it, it will work for both PocketPC 2003 and Windows Mobile 5 (i.e. the functional PPC2003 app will also run on a WinMo5 device).

The CameraCaptureDialog is nearly useless, so you're not losing much there. Ideally, as a programmer you'd want the camera interface to be controllable programmatically (i.e. set the resolution, switch from camera to video, take the picture etc.), but it really doesn't let you do anything other than open the device's built-in interface.

Update: Here is the sample application I mentioned:

http://blogs.msdn.com/b/marcpe/archive/2006/03/03/542941.aspx

And I misremembered: this sample will not work in PocketPC 2003 (only in Windows Mobile 5 and up). There is no way that I know of to access the device camera in PocketPC 2003. At least there is no device- and/or manufacturer-independent way of accessing the camera. With some devices (the HP iPaq, for example) the manufacturer exposes camera functionality through a DLL already present on the device (which you can access via P/Invoke).

If you need camera integration, the device has to be running Windows Mobile 5 (or newer). Some devices can be upgraded to a newer version of the OS, but I'd definitely have to question that move. Better to move to a more modern device (like the Droid, for example).

MusiGenesis
Thanks for the reply. I do not care at all if PPC2003 users are not able to take a picture from our app. I only want to find a way to be able to do so from WindowsMobile5 and later, but -- and this is what I'm stuck on -- I don't want to have to build a separate project -- so I think I just need a way to only load the WindowsMobile.forms.dll at run time (if it exists).As for targeting more modern devices -- our customers are using the app on heavy duty Intermec and Symbol pocketpc's, that are ridiculously overpriced, but, I gotta admit, sturdy as tanks.
KenF
Intermec PDAs are the only reason I'm still writing code for Windows Mobile, so I understand. It may be possible to call a method in `Microsoft.WindowsMobile.Forms` via Reflection; if so, you can just check the OS version and only call the camera method if you're on WM5+. If the DLL can't be accessed via Reflection, you should be able to make a separate DLL project (a WM5 project) that wraps the CameraCaptureDialog calls. You should be able to then call your separate DLL's methods based on what OS you're running.
MusiGenesis
Awesome, I went with the WinMobile sub-project .dll, and everything compiles fine, and still runs fine on an old PPC 2003 device. Thanks again!
KenF