Home About Me Follow Me on Twitter @mikefrancis Subscribe Resources
# Wednesday, November 11, 2009

I’ve had a couple of clients that ran into a problem where their SMS Message interceptor would fail to fire. (For an introduction to this pretty cool technology see here.) This was a hard to track down problem, because the interceptor would work on some devices, and the emulator, but not on a handful of devices. Because this worked on several devices, it seemed the code was without errors.

We resolved this by determining if any of the existing SMS interceptors were interfering with this one. SMS Interceptors fire in a chain with each one handing off to the next. That is they should hand-off. If you are implementing a native code interceptor using IMailRuleClient, you can stop the message processing by setting the handled flag to MRC_HANDLED_DONTCONTINUE. This prevents any further processing of the message. However, this flag should ONLY be used if the message you are receiving is private to your application / interceptor. If other interceptors could possibly process the message, you should set the handled flag to MRC_HANDLED_CONTINUE or MRC_NOTHANDLED. For managed code, if you would like the message to be available to other interceptor applications, create the MessageInterceptor instance passing the InterceptionAction.Notify enumeration value to the MessageInterceptor constructor.

You can test for interfering interceptors by going to [HKEY_LOCAL_MACHINE\Software\Microsoft\Inbox\Svc\SMS\Rules] and set each rule to ‘0’ until the problem goes away. The last rule you change to ‘0’ before the problem goes away will be the problematic rule. Note that you need to soft reset the device after changing the registry key.

For example:

[HKEY_LOCAL_MACHINE\Software\Microsoft\Inbox\Svc\SMS\Rules]
"{27E9801F-330B-4c6a-A7BF-A670D8C53C5D}"=dword:00000001
"{E85FD9C3-4F5E-4c75-8C21-0F850274DEF5}"=dword:00000001 <- Change to 0 to test

Once you have located the problematic rule, you can get more information on it (for example, the DLL name) by searching for the GUID underneath HKEY_CLASSES_ROOT\CLSID.

 

Thanks,

Mike

posted on Wednesday, November 11, 2009 8:03:06 PM UTC  #    Comments [2] Trackback
# Friday, November 06, 2009

Some developers are reporting a problem with the PNG icon not displaying in the Start screen.The usual symptom is that it does not show up immediately after installation but is seen after a device reset. This problem occurs if following the static cab method from the blog post: Using Custom Icons in Windows Mobile 6.5. I can reproduce this pretty consistently by installing again after initially installing. (During this process the first installation is uninstalled.) The static method does not use a setup DLL, but instead uses CAB file directives that are easily specified using Visual Studio to define the installation destination, files to be installed, the program shortcut, and any necessary registry keys.

So why is this happening?

For the PNG file to be displayed, the following sequence must take place, the next step dependant on the next:

  1. Copy the PNG File to the destination directory
  2. Create the registry key pointing to the PNG file
  3. Create the program shortcut

When the shortcut is created the shell will:

  1. Use the shortcut (.lnk) file specified in step 3 above, and look up the registry key specified in step 2 above. The registry key needs to exist for this step to succeed.
  2. Open the PNG file, based on the registry key, and cache the Start screen icon.
  3. If you look at the _setup.xml that is included CAB file, you can see the order of events:
   1: <characteristic type="%CE11%" translation="install">
   2: <characteristic type="MakeDir" />
   3: <characteristic type="SMS Intercept.lnk" translation="install">
   4: <characteristic type="Shortcut">
   5: <parm name="Source" value="%InstallDir%\sms Intercept.exe" translation="install" />
   6: ...
   7: <characteristic type="Registry">
   8: <characteristic type="HKLM\Security\Shell\StartInfo\Start\SMS Intercept.lnk">
   9: <parm name="Icon" value="%InstallDir%\AppIcon.png" datatype="string" translation="install" />
  10: </characteristic>

Note that the instructions to create the shortcut appear sooner in the file than those for the creation of the registry key. In most cases, the timing is such that despite this order, the registry key is in place by the time the shortcut cut is actually created. If the registry key pointing to the location of the PNG file does not exist when the shortcut is created, the PNG icon will not be created.

Unfortunately the order of these events cannot be changed in the Visual Studio project or by reordering the directives in the .INF file.

The workaround is to append the XML for the shortcut creation to the CAB file. This will ensure that the shortcut creation is the last instruction to be processed. You can do this by following these steps:

  1. Remove the shortcut directive from your Smart Device CAB file project in Visual Studio.
  2. Modify the following XML (lines 4 and 6) to match your application:

   1: <characteristic type="FileOperation">
   2:     <characteristic type="%CE11%" translation="install">
   3:     <characteristic type="MakeDir" /> 
   4:         <characteristic type="SMS Intercept.lnk" translation="install">
   5:         <characteristic type="Shortcut">
   6:             <parm name="Source" value="%InstallDir%\sms Intercept.exe" translation="install" /> 
   7:         </characteristic>
   8:         </characteristic>
   9:     </characteristic>
  10: </characteristic>

  1. Save this to a file: shortcut.xml
  2. Get the command line used by CABWIZ to build your CAB file. We are going to use this to build a Post Build step.
    1. Build your CAB file project.
    2. Open the Output window in Visual Studio and you should see something like:

Building file 'C:\Projects\sms Intercept\sms Intercept\sms Intercept\CAB Static\Static CAB\Debug\StaticCAB.cab'...

"C:\Program Files\Microsoft Visual Studio 9.0\smartdevices\sdk\sdktools\cabwiz.exe"
     "C:\Projects\sms Intercept\sms Intercept\sms Intercept\CAB Static\Static CAB\Debug\StaticCAB.inf"
     /dest "C:\Projects\sms Intercept\sms Intercept\sms Intercept\CAB Static\Static CAB\Debug\"
     /err CabWiz.log

  1. Modify your Visual Studio main application project, to include a post build event. (Project | Properties | Build Event) (Ideally we would do this as part of building the CAB file, but Smart Device CAB projects do not include pre or post build events.)
    1. Paste in the command line with the switch (/postxml) to add the shortcut.xml file into the Post Build event command line:

      "C:\Program Files\Microsoft Visual Studio 9.0\smartdevices\sdk\sdktools\cabwiz.exe"
           "C:\Projects\sms Intercept\sms Intercept\sms Intercept\CAB Static\Static CAB\Debug\StaticCAB.inf"
           /postxml "C:\Projects\sms Intercept\sms Intercept\sms Intercept\CAB Static\Static CAB\Shortcut.XML"
          
      /dest "C:\Projects\sms Intercept\sms Intercept\sms Intercept\CAB Static\Static CAB\Debug\"
           /err CabWiz.log

  2. Now when you build the main project, your CAB file will also be built, with instructions in the XML in the correct order.

The static cab project in the PNG Start screen sample with the above implemented can be found here.

I realize this is not the cleanest solution – but it will resolve the problem of the PNG icon sometimes not being displayed if using the static CAB deployment method. At least, you still don’t have to write / maintain any C++ code to support the PNG icon.

Enjoy-

Mike

posted on Friday, November 06, 2009 2:30:44 AM UTC  #    Comments [2] Trackback
# Sunday, November 01, 2009

I just posted on the Windows Mobile Developers team blog: The Windows Marketplace for Mobile Client and your Setup code. This article reviews some potential ‘gotchas’ if you include custom UI in your setup DLL that is being called by the Marketplace client. The message is, please don’t add custom UI. Why? Because it makes the install experience less uniform and streamlined. If you really, really must add you custom UI, the information in this post should be useful to you.

Enjoy,

Mike

posted on Sunday, November 01, 2009 10:29:50 PM UTC  #    Comments [0] Trackback
# Saturday, September 26, 2009

After a some great feedback from developers writing application for the Windows Marketplace for Mobile, I have updated the companion sample code that goes with the Windows Team blog post Using Custom Icons in Windows Mobile 6.5. You can download it from the blog post or here.

Enjoy!
Mike

posted on Saturday, September 26, 2009 5:04:03 PM UTC  #    Comments [0] Trackback
# Tuesday, August 11, 2009

A new release of the Windows Marketplace for Mobile requirements went live today. Many developers should be happy with change in the PNG Start screen icon requirements. Prior to today, you were required to include three PNG files (one for each possible DPI) in your installation CAB file. Today, this requirement is one (90x90) icon.

The three icon requirement, necessitated a setup DLL to dynamically copy the appropriate PNG according to the device DPI. Now the setup is much easier – only requiring CAB file definitions and no C++ code. 

For more information see the following updated blog post: Using Custom Icons in Windows Mobile 6.5 and FAQ: Start Screen PNG Icon FAQ.

Mike

posted on Tuesday, August 11, 2009 7:06:07 PM UTC  #    Comments [0] Trackback
# Sunday, August 09, 2009

If you are new to Windows Mobile development or are interested in a consolidated list of resources, check out the list I’ve put together here: Resources: Windows Mobile Development.

This list was easy to put together using Delicious linkrolls (mmmm linkrolls…). If you have Windows Mobile links to recommend, please add me to your Delicious network. I use the tag: windowsmobile.

Mike

posted on Sunday, August 09, 2009 6:20:09 PM UTC  #    Comments [0] Trackback
# Thursday, August 06, 2009

image There have been a lot of questions around how to create great looking icons like you see for the Microsoft apps in the Windows Mobile 6.5 Start screen.  These icons aren’t icons at all in the traditional sense. Up until Windows Mobile 6.5, you could only use icon (.ICO) images embedded in the EXE file for your Start menu icon. The new Windows Mobile 6.5 Professional Start screen still uses these icons, but you may notice that they are scaled slightly. You may not notice any difference in the appearance of the icon, if you do, you can use a PNG file for your application icon. If fact, the Windows Marketplace for Mobile requires that you use a PNG for Windows Mobile 6.5 applications.

For details on now to specify a PNG file for your Start Screen icon see my blog post here.

posted on Thursday, August 06, 2009 5:43:31 AM UTC  #    Comments [0] Trackback
# Friday, July 24, 2009

Need to create PNG files for your Windows Mobile 6.5 applications? Check out my blog post on the main Windows Mobile blog here.

Mike

posted on Friday, July 24, 2009 6:14:47 PM UTC  #    Comments [0] Trackback