Category: Windows Mobile

  • Unlock Orange SPV C600 AKU 2.0 For Development

    When Orange released their AKU 2.0 ROM for the C600 it introduced a much tighter security policy. A previous loophole for changing security policies involving a signed registry editing application was closed by black-listing the app. Also the online unlocking page from the Orange Developer program doesn’t recognise a C600 IMEI. Luckily there is a process in place to get your device unlocked for development and testing. Here are the steps to take, you’ll get up and running in a day or two:-


    Send an email to developers [at] orange [dot] com


    Make sure you include all the following information:-



    • IMEI of the phone exactly as displayed when you dial *#06# (17 digits long)

    • Your full name

    • Your orange network country

    • Phone number for the handset (must be an orange number)

    • Full model number of the device

    Using this information they prepare a special unlocking app specific to your device, you should get this back within a couple of days. They will send you this as a zip file with an executable which will run on your desktop and install the component to your device over ActiveSync. On your Smartphone you can then run the tool from Start > Accessories > Security Levels. You can then change the security model to Disabled, Low or High at any time. Turn the phone off and on again for the change to take full effect.

  • Writing Provisioning XML for Windows Mobile

    This recent article discussed one of the ways you can use XML provisioning data – through a cab file installation. You can also pass the XML to DMProcessConfigXML or ConfigurationManager.ProcessConfiguration in the managed world. But how about creating the XML?


    Well you could use notepad and code it all by hand as a worst-case-scenario. The next best thing is to use the XML support in Visual Studio which will at least help to ensure you write valid XML. Mobile In The Hand 2.0 takes this one step further by adding a schema into VS2005 to ensure your document conforms to the msprov schema:-


    1. Create a new XML document in your project


    2. With the document selected locate “Schemas” in the properties pane.



    3. Click “…” to bring up a list of installed schemas



    4. Select msprov from the list


    5. Start writing your document and watch the intellisense kick in

  • Contact.WebPage

    The Managed APIs in Windows Mobile 5.0 expose the Contact.WebPage as a Uri. The problem with this approach is that the user forms are free text and you can enter anything into this field. Probably 9 times out of 10 you’ll enter an address such as


    www.peterfoot.net


    And because the managed API passes this to the Uri constructor and it has no http:// prefix it fails and returns null. However there is a solution to workaround the issue. You can access the Properties collection and access the property and it will be returned as a string. So for example you would use:-


    [C#]
    string webPage = session.Contacts.Items[0].Properties[Microsoft.WindowsMobile.PocketOutlook.ContactProperty.WebPage];

    [VB]

    Dim webPage As String = session.Contacts.Items(0).Properties(Microsoft.WindowsMobile.PocketOutlook.ContactProperty.WebPage)


    If you then want to use a Uri with this value, check to see if it includes the http:// prefix and if not add your own e.g.


    Uri contactsWebpage = new Uri(“http://” + webPage);


     

  • GetDeviceUniqueID For VB

    To complement the C# version posted Here,  here is a working VB translation:-

    <System.Runtime.InteropServices.DllImport(“coredll.dll”)> _
    Private Shared Function GetDeviceUniqueID(ByVal appdata As Byte(), ByVal cbApplictionData As Integer, ByVal dwDeviceIDVersion As Integer, ByVal deviceIDOuput As Byte(), ByRef pcbDeviceIDOutput As Integer) As Integer
    End Function

    Private Function GetDeviceId(ByVal appData As String) As Byte()

    Dim appDataBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(appData)
    Dim outputSize As Integer = 20
    Dim output(19) As Byte

    Dim result As Integer = GetDeviceUniqueID(appDataBytes, appDataBytes.Length, 1, output, outputSize)

    Return output

    End Function

  • Any Port in a Storm

    A user posted an important observation on the Bluetooth COM support in Windows Mobile 5 here on the microsoft.public.pocketpc.developer newsgroup. The problem is that while the system allows you to create virtual COM ports for all your paired devices which support Serial Port Profile, most of the time this will fail because the COM port you pick is already in use, on many devices you can have just 2 virtual COM ports. I’ve posted a few of my thoughts in the thread linked above, but while there are things that Microsoft can work to improve there are also a few things that developers can do to avoid the problem:-



    • Don’t rely on the control panel for setting up ports, use the RegisterDevice route (or BluetoothSerialPort in 32Feet.net) to just register a port for the duration you need it (and possibly reuse the same port name). This also allows you to use a different port prefix since few COMx: ports are available out of the box.

    • Don’t use serial ports. Unless you need your device to be accessible by a legacy app then you can avoid using virtual COM ports altogether and work directly with Sockets (again 32Feet.net will allow you to setup these connections easily). The downside with this approach is it applies only to the Microsoft Bluetooth Stack, as the programming model for the main alternative from Broadcom is essentially based around ports. However based on the first batch of devices released with Windows Mobile 5.0 the Broadcom stack is a lot less common.

  • Determine WM5.0 AKU Version Programmatically

    The full build and AKU version of a device is shown on the Start > Settings > System > About screen, however what if you want to determine the version from your code. Well starting with Windows Mobile 5.0 there is now a registry key which holds the AKU version e.g.


    RegistryKey kAku = Registry.LocalMachine.OpenSubKey(“SystemVersions”);

    string akuVersion = kAku.GetValue(“Aku”, “”);

    kAku.Close();


    This version will include a leading period so for example if the string is “.0.1.1” as on the current JasJar ROM the device has AKU 0.1, if it reads “.1.1.0” as on the current K-Jam ROM you have AKU 1.1. As far as I’m aware all shipping devices will have at least 0.1 as some fixes were implemented between RTM in May 2005 and the first shipping devices released later in the year. If your version is “.2.x.x” then you are a very lucky bunny indeed!


    Whilst Windows Mobile 2003 had a similar concept of periodic AKU updates throughout it’s lifetime this registry key is not available, nor is the AKU version displayed on the About dialog, only the Build number is displayed.

  • KeyboardPresent always returns false

    This bug affects both managed and native developers working with the Windows Mobile 5.0 SDK.


    Native


    Due to an error in snapi.h the location of the registry key used to indicate if a hardware keyboard is present is incorrect:-


    ////////////////////////////////////////////////////////////////////////////////
    // KeyboardPresent
    // Gets a value indicating whether a keyboard is attached and enabled.
    #define SN_KEYBOARDPRESENT_ROOT HKEY_LOCAL_MACHINE
    #define SN_KEYBOARDPRESENT_PATH TEXT(“SoftwareMicrosoftShell”)
    #define SN_KEYBOARDPRESENT_VALUE TEXT(“HasKeyboard”)


    The root key for this value should instead be HKEY_CURRENT_USER. Once you use this location you can correctly determine if there is a hardware keyboard (this is the same location as used on WM2003 Second Edition devices such as the HTC Blue Angel).


    Managed


    The SystemState class also uses the incorrect location to read this value so the property will always return false. The workaround here is to access the registry directly using either the Microsoft.Win32.RegistryKey in .NETCF v2.0 e.g.


    RegistryKey keyboardKey = Registry.CurrentUser.OpenSubKey(“SoftwareMicrosoftShell”);

    int dwHasKeyboard = keyboardKey.GetValue(“HasKeyboard”, 0);

    keyboardKey.Close();

    bool hasKeyboard = (dwHasKeyboard != 0);

  • Bug in Microsoft.WindowsMobile.Telephone.Phone.Talk

    Luis Cabrera has posted the details of a bug identified in the Talk method to the Windows Mobile Team blog. The workaround (see the original post) is to append a null character to the end of your dial string.


    Note: this bug doesn’t affect InTheHand.WindowsMobile.Telephony.Phone.Talk.

  • The ItemId in Managed PocketOutlook

    The ItemId type is introduced to the managed APIs to represent either a POOM Oid (int) or MAPI ENTRYID (16/14 bytes). It doesn’t directly expose the underlying data but there are a couple of useful behaviours:-



    • ItemId constructor accepts an int to create an ItemId from an existing known Oid value
    • For POOM items (Appointment, Contact, Task) calling GetHashCode() on the ItemId returns the underlying Oid. However since this behaviour is not specifically documented it cannot be relied upon to stay this way in a future version.
    • Oids on Windows Mobile 5.0 are created differently to previous versions. On older platforms the Oid is the identifier of the CEDB database record containing the item. On Windows Mobile 5.0 the databases are housed in an EDB database. Here the POOM Oid is a separate field containing a unique id and the item type, therefore it’s possible to infer the type from an Oid unlike previous versions – 0x4000001 would be an Appointment, 0x80000001 a Contact and 0xC0000001 a Task.

  • PocketOutlook Native Managed Map

    Windows Mobile 5.0 introduces a managed API which wraps both POOM and a subset of CEMAPI (enough to send an Email / Sms). The table below is designed to show how the managed objects map to the interfaces which will be familiar to seasoned POOM developers. It also shows those parts of POOM which are not available through the managed APIs:-

















































































































































































































    Native


    Managed


    IPOutlookApp


    OutlookSession


    · Logon


    Automatically handled


    · Logoff


    Automatic – call Dispose on your OutlookSession when finished


    · get_Version


    Not Supported – Get OS version with System.Environment.OSVersion.Version


    · GetDefaultFolder


    Use strongly typed folder properties – Appointments, Contacts & Tasks


    Infrared not supported


    · CreateItem


    Use default constructor for specific item type


    · GetItemFromOid


    Use constructor for item which accepts an ItemId e.g.


    new Contact(new ItemId(oid)


    · City Methods (Removed in Pocket PC 2002)


    Obsolete


    · ReceiveFromInfrared (Obsolete from Pocket PC 2002)


    Obsolete


    · get_OutlookCompatible


    Obsolete


    · GetTimeZoneFromIndex


    Not Supported


    IFolder


    Folder – AppointmentFolder, ContactFolder, TaskFolder


    Infrared not supported


    · get_Items


    Items


    · get_DefaultItemType


    N/A inferred from the Folder type


    · get_Application


    N/A


    · AddItemToInfraredFolder


    Not Supported


    · SendToInfrared


    Not Supported


    · ReceiveFromInfrared


    Not Supported


    IPOutlookItemCollection


    PimItemCollection – AppointmentCollection, ContactCollection, TaskCollection


    · Add


    Add


    · get_Count


    Count


    · Find


    Find (Requires a PropertyDescriptor)


    · FindNext


    Not Supported


    · Item


    · 1-based index


    Default indexer – () VB or [] C#


    0-based index


    · Remove


    RemoveAt – also implements Remove(PimItem)


    · Restrict


    Restrict


    · Sort


    Sort


    · get_IncludeRecurrences


    Not Supported


    · put_IncludeRecurrences


    Not Supported


    IAppointment


    Appointment


    · ClearRecurrencePattern


    Call Clear on the AppointmentRecurrence


    · GetRecurrencePattern


    RecurrencePattern


    · get_* / put_*


    Accessible by named properties or via Ids through the Properties collection


    · Save


    Update


    · Send


    Send


    · Delete


    Delete


    · Cancel


    Cancel


    · Copy


    Copy


    · Display


    ShowDialog


    · get_Oid


    ItemId


    · get_BodyInk / put_BodyInk


    BodyInk no longer supported on WM5.0


    IContact


    Contact


    · get_* / put_*


    Accessible by named properties or via Ids through the Properties collection


    · Save


    Update


    · Delete


    Delete


    · Copy


    Copy


    · Display


    ShowDialog


    · get_Oid


    ItemId


    · get_BodyInk / put_BodyInk


    BodyInk no longer supported on WM5.0


    ITask


    Task


    · ClearRecurrencePattern


    Call Clear on the TaskRecurrence


    · GetRecurrencePattern


    RecurrencePattern


    · get_* / put_*


    Accessible by named properties or via Ids through the Properties collection


    · Save


    Update


    · Delete


    Delete


    · SkipRecurrence


    Call Skip on the TaskRecurrence


    · Copy


    Copy


    · Display


    ShowDialog


    · get_Oid


    ItemId


    · get_BodyInk / put_BodyInk


    BodyInk no longer supported on WM5.0


    IItem


    New in WM5.0 supports access to custom properties etc Functionality is available via Appointment, Contact and Task types


    IRecipients


    RecipientCollection


    Shared with the Email (MAPI) support


    IRecipient


    Recipient


    Shared with the Email (MAPI) support


    IRecurrencePattern


    Recurrence – AppointmentRecurrence, TaskRecurrence


    Properties follow same names as native equivalent. Managed types such as TimeSpan and DateTime are used as appropriate. Enums defined for Months, WeekOfMonth, DaysOfWeek


    IExceptions


    Not supported


    IException


    Not supported


    ITimeZone


    Not supported