Tuesday, 19 June 2007

DeviceEmulator Slow?

Recently I was working with DeviceEmulator on Windows CE 6.0 and it seemed slow. If you are using Windows CE 6.0 and you would like debug OS images to be a little more responsive when running on DeviceEmulator here’s a couple of things we found that you can try.

Add a DWORD value in HKCU\Software\Microsoft\Platform Builder\6.00\Debug called "SynchronousDebugMessage" and set it to 0.

This tip found here:
http://groups.google.com/group/microsoft.public.windowsce.platbuilder/browse_thread/thread/860b1ff6347ed62c/0d3af9395d161fce?lnk=st&q=%22(un)load%22+windowsce&rnum=3&hl=en#0d3af9395d161fce

The other thing you can try is to ignore module loads until later.
Go to target->connectivity options dialog
Switch to the "service status" tab
Click "settings" for "Kernel Debugger OS Awareness".
Switch the "Module (un)load notification to the debugger" option

The help from the dialog says the following options are available:
Always off: Never catch notification, module changes are updated on each halt. Boot time and execution is fast, real-time, but breakpoints cannot be instantiated on time.
Always on: Catch notification of all module changes immediately. Boot time and execution is slow, non real-time, but breakpoints can be instantiated on time.
Off until first halt: Suppress notification until first target halt, then catch all notifications.

This tip found here:
http://groups.google.com/group/microsoft.public.windowsce.platbuilder/browse_thread/thread/860b1ff6347ed62c/0d3af9395d161fce?lnk=st&q=%22(un)load%22+windowsce&rnum=3&hl=en#0d3af9395d161fce

Command line (Console) over serial

I'm a big fan of command line access, if you've got a headless device or a device with a custom shell / UI this tweak is really useful...!

To configure the command processor shell on windows CE to run over a serial connection add the following to your registry

[HKEY_LOCAL_MACHINE\Drivers\Console]
OutputTo = REG_DWORD:1 // Redirects CMD to COM1
COMSpeed = REG_DWORD:19200 // Speed of serial connection

This redirects all input and output for all console applications to the serial port, hmm wonder if it'll work with bluetooth as well... :)

Thursday, 14 June 2007

Using Image Factory under CE/Windows Mobile

Having trouble getting Windows CE/Windows Mobile factory working to load pictures?

The code below will load a JPG/GIF/PNG (or whatever decoders are installed on your device) etc from a file and paint it to the screen:

CoInitializeEx(NULL, 0);
IImagingFactory* pImageFactory;
IImage *pImage = NULL;

HDC dc = GetDC(0); // insert your window handle here, else this is the desktop

HRESULT hr = CoCreateInstance(CLSID_ImagingFactory, NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IImagingFactory),
(LPVOID *)&pImageFactory);

// Load image from file
pImageFactory->CreateImageFromFile(bitmapName, &pImage);

// Get image information
ImageInfo info;
pImage->GetImageInfo(&info);

RECT rc={0,0,info.Width, info.Height};

// draw jpg/gif etc onto temp dc
pImage->Draw(dc, &rc, NULL);

// Clean up
pImage->Release();
pImageFactory->Release();

CoUninitialize();



Wednesday, 13 June 2007

Memory Leaks with MFC CPtrArray


Just finished debugging some 3rd party code with memory leaks.

The code used the RemovalAll member operation on the MFC CPtrArray class. This operation needs to be used with care as all the array elements need to be deleted AFTER the call to RemoveAll. Calling RemoveAll before deleting all the array objects will cause a memory leak.
Another memory leak was caused by deleting a class pointer that had been passed to a function as a void pointer. When delete is executed on a void pointer the destructor of the class is obviously not called.

One final comment on memory leaks fixing is beware when using the EVC4 debug environment. Over the past few days I was chasing a memory leak that did not exist but was a symptom of using the debugger!

Tuesday, 12 June 2007

Windows Mobile Device Center 6.1 for Windows Vista

You can now find the latest release of WMDC version 6.1 available.


The key updates delivered in this release include:

  • IRM activation
  • HTML mail
  • Certificate enrollment
  • File synchronization on all WM 6 devices (Yes, even Smartphone!)
  • Windows Embedded CE 6.0 support
  • Automatic device authentication
  • Product registration
  • Silent-mode install for corporate deployment
    And more!

But from our basic testing it looks like it solves the previous versions problem which is connecting Vista to a Windows Embedded CE device via it's Activesync module. Even though the MS official descriptions only indicate WinCE 6.0 I have had it tested with a WinCE 4.2 device (seen here). So I see no reason why it's not going to work with 4.0, 4.2 & 5.0 etc.