# Friday, June 07, 2013

Moving from WinForms to XAML Runtime on Windows Embedded Compact

I recently found an old set of slides I created for TechEd NZ a few years ago which collected together useful information for moving from Windows Mobile to Windows Phone. It struck me that some of this would also be useful for the Embedded XAML Runtime when considering moving code from a traditional WinForms UI to a XAML based UI using Xaml In The Hand. I've modified the table listing controls in both UI worlds and added it to the Knowledge Base here:-

http://inthehand.uservoice.com/knowledgebase/articles/209986-winforms-versus-xaml-runtime-controls

While most of this still applies to Windows Phone (and with a few further changes Windows Store apps) there are items here which are specific to Windows Embedded Compact - The ComboBox control which doesn't exist on Phone (although there is a perfectly good alternative), and the MediaElement and WebBrowser controls which don't exist in the XAML Runtime but for which we have created managed code controls which expose the same XAML and C# interfaces.

#    |
# Saturday, April 20, 2013

Use Team Foundation Service for Embedded Projects

Microsoft's hosted TFS (http://tfs.visualstudio.com/) provides a cloud hosted TFS project collection which is free for small teams. It works neatly with VS2012 which is fine for Windows Store and Windows Phone project types but for .NET Compact Framework development we are still stuck with using Visual Studio 2008. Luckily with a few patches it is possible to connect to a Team Foundation Service collection from Visual Studio 2008. I recently had to rebuild my Windows 8 desktop machine so for reference thought I would blog the instructions for setting this up. You'll need to install the items in the following order:-

No before you ask I didn't make up the name of that last one, I actually shortened it for you :-)

To open a project from the server open your shiny up-to-date VS2008 IDE and go to File > Source Control > Open from Source Control. You'll get a blank dialog with a drop down box for servers and an empty list of projects. Select the Servers... button and then click Add..

You'll notice that after these updates the dialog allows you to enter a fully formed Url for the server and will grey out the connection details below. You must specify https and include the DefaultCollection indicator, this Uri will always be of the form <yourchosenname>.visualstudio.com. When you click okay VS2008 will connect to the service and then prompt you to authenticate with your Microsoft ID. Once this is successful you'll see the following:-

 

It will show you the display name of the account you are logged in as at the bottom left (not on this shot) and a Sign Out option. Things get a little complicated if you regularly use different Microsoft IDs because you can get into a situation where VS2008 shows error messages from the service but doesn't show what account it thinks you are logged in as or give the option to log out and back in with different credentials. Still haven't found a neat way around this yet other than making sure you log out from your Microsoft ID in your browser and possibly also the browser within the VS shell. It seems to be a cookie issue and possibly compounded if you use a Windows 8 account signing in with your Microsoft ID. If you've successfully got to this step you can select a project, assign a local path and work as you would with a local TFS back end. As well as the source control the work items sync back and forth with the web front end. I don't think there is any capability to use the "Preview" build services for Embedded projects and doubt if this functionality will be added.

#    |
# Monday, October 15, 2012

WriteableBitmapEx for Windows Embedded Compact 7

I have ported René Schulte's excellent WriteableBitmapEx project to run on Windows Embedded Compact 7. The original library supports drawing across various XAML user interfaces - Silverlight, Windows Phone, WPF and Windows 8 Apps. Because XAML In The Hand exposes an object model which matches Silverlight there was very little work required to port, it just needed a new Dll project for .NETCF 3.5 and a reference to the XAML In The Hand DLL. This allows a whole range of complex drawing operations to be performed where using Silverlight Paths and Shapes would be inefficient.

WriteableBitmap for Windows Embedded

Performance will vary more because the range of hardware platforms available for Windows Embedded Compact varies considerably, both in processing power and screen sizes. I've tested the code on FreeScale development boards at up to 1024x768 and on the new Motorola WT41N1 Wearable Computer which has a small 320x240 resistive touch display with encouraging results. Writing XAML user interfaces for embedded devices is incredibly easy once you've experienced the Windows Phone and desktop tools. With built in support for touch and dynamic layouts and all the animation and data-binding you would expect it allows you to write fluid user interfaces for specialist devices where a consumer phone or tablet would be impractical. More information on XAML In The Hand is available here

 

#    |
# Monday, September 03, 2012

Connect Visual Studio 2008 to TFS2012 or Team Foundation Service Preview

Now that there is a new release of Team Foundation Server you may consider upgrading. However if you still work on projects for the .NET Compact Framework you'll still be using Visual Studio 2008. Luckily there is an update available to allow VS2008 to connect to a TFS2012 server or the new Team Foundation Service Preview (hosted TFS - why not check it out with a free preview account). You'll need VS2008 Service Pack 1 installed first (but you've got that already right!). The download and instructions are available here:-

http://support.microsoft.com/kb/2673642

#    |
# Thursday, May 03, 2012

Windows Marketplace for Mobile 6.x to be Discontinued

If you publish apps on the old Marketplace for Windows Mobile 6.x you should have received reminders that the service will be discontinued in two weeks. If you have been using our Mobile In The Hand product with a managed code app there are a couple of issues to be aware of. Our libraries contain the following two classes to provide programmatic access to the Marketplace client on Windows Mobile 6.x:-

  • InTheHand.Phone.Tasks.MarketplaceDetailTask
  • InTheHand.Phone.Tasks.MarketplaceLauncher

If these are called on a device with the Marketplace client installed they will launch the client application however once the service is discontinued no application details will be accessible so this may result in a confusing experience for your users. Consider these classes obsolete as they will no longer be supported and will be removed from the next release.

https://inthehand.uservoice.com/knowledgebase/articles/72785-windows-marketplace-for-mobile-6-x-to-be-discontin

#    |
# Tuesday, April 19, 2011

Managing Processes and Memory With Mobile In The Hand 7.0

.NET Compact Framework

The Compact Framework provides the capability to start a separate process from your code, and stop it but it doesn’t give you more detailed information about what is running and what components are in use. Windows CE includes the optional ToolHelp component (present in all Windows Mobile versions). The InTheHand.Diagnostics namespace includes a number of classes for working with ToolHelp in a way which matches the full .NET Framework. The ProcessHelper class includes the GetProcesses() static method to return all running processes on the device. Extension methods GetModules() and GetThreads() return ProcessModule and ProcessThread collections for a specific Process.

ProcessModule exposes name, size and version information for an individual module. ProcessThread exposes id, priority and elapsed processor time.

Another way you might want to interrogate a process is to determine the memory usage. For your own process we’ve followed the Windows Phone model and so InTheHand.Phone.Info.DeviceExtendedProperties.ApplicationCurrentMemoryUsage

provides you this useful figure as a strongly-typed property. It is also accessible from the GetValue method as you would on Windows Phone.

Windows Phone

Other than the built in set of tasks you can’t start any other applications or tell if they are running. You do have access to memory statistics though which are accessible from the Microsoft.Phone.Info.DeviceExtendedProperties class. A limitation here is that if you use this method to get the memory statistics your app will automatically get marked as requiring the ID_CAP_IDENTITY_DEVICE capability which it doesn’t actually need for these properties. We built a helper class for two reasons – firstly to remove this requirement and secondly to provide strongly-typed properties as an alternative to the GetValue implementation. On Windows Phone therefore you can use:-

InTheHand.Phone.Info.DeviceExtendedProperties.ApplicationCurrentMemoryUsage

InTheHand.Phone.Info.DeviceExtendedProperties.ApplicationPeakMemoryUsage

and

InTheHand.Phone.Info.DeviceExtendedProperties.DeviceTotalMemory

Mobile In The Hand 7.0

Mobile In The Hand is a suite of components for developing mobile applications across Microsoft’s various mobile and embedded operating systems. It will save you development time and allow you to share more code across different .NET project types.

#    |
# Friday, April 15, 2011

Geocoding and Reverse Geocoding with Mobile In The Hand 7.0

This is the first in a series of posts about Mobile In The Hand 7.0 which brings a collection of reusable components to the .NET Compact Framework. This latest version is updated to support all versions of Windows Mobile including Windows Embedded Handheld, All versions of Windows Embedded Compact (in it’s various names) from 4.1 to 7.0 and a set of companion libraries offering a subset of the functionality on Windows Phone 7.

When the .NET Framework 4.0 was released it introduced a new namespace – System.Device.Location which provided a range of location features. Subsequently this was used as the model for Windows Phone’s APIs. One major whole in the Windows Phone implementation is that the CivicAddressResolver is not implemented and doesn’t return a result. Mobile In The Hand 7.0 comes to the rescue with a two pronged attack:-

An InTheHand.Device.Location.GeoCoordinateWatcher for the .NET Compact Framework. This uses the GPS Intermediate driver present on all Windows Mobile 5.0 and later devices and available as a system component on Windows CE 6.0 and beyond. This is exposed with a familiar object model which matches that found in .NET 4.0 and Silverlight for Windows Phone.

Secondly two new components are provided – BingCivicAddressResolver takes a GeoCoordinate and uses Bing Maps to resolve a CivicAddress object similar to the functionality available on desktop windows. Additionally as an extra feature the BingGeoCoordinateResolver allows you to resolve a GeoCoordinate from an address or partial address. Both of these classes are provided in the .NET Compact Framework and Silverlight for Windows Phone libraries which make up Mobile In The Hand 7.0. The Compact Framework version offers both Synchronous and Asynchronous calls, the Silverlight version just exposes the Asynchronous calls.

#    |
# Monday, May 10, 2010

Mobile In The Hand 4.2 Released

This latest update includes a number of performance enhancements and wider device compatibility.

A new SystemEvents class is added in the InTheHand.Win32 namespace which allows you to monitor power changes on devices which do not support the State and Notifications Broker (Pocket PC 2003 and all Windows CE devices).

InTheHand.Net.WebUtils provides a method to safely encode/decode strings in a HTML/XML friendly way.

InTheHand.WindowsMobile.Status.SystemState now supports more properties on Pocket PC 2003 and Windows CE devices by interfacing with lower level APIs on these devices.

This is a free update from v4.x. Registered users of v3.x can purchase a reduced price upgrade. Full product details here:-

http://inthehand.com/content/mobile.aspx

 

#    |
# Tuesday, March 16, 2010

Mobile In The Hand 4.1

While this week has very much been focussed on Windows Phone 7 so far we also released the latest version of our Mobile In The Hand suite for the .NET Compact Framework. Along with some bug-fixes (several around EmailMessage functionality) and performance improvements there are a lot of new features in this release. These include:-

  • Compatibility – We have gone through the entire library and documented which platform versions support which features in a similar way to the MSDN documentation for the underlying APIs. We have also added in more platform checks and workarounds so we are now able to support a much wider range of devices. Pocket PC 2003, Windows Mobile 5.0, Windows Mobile 6, Windows Mobile 6.1, Windows Mobile 6.5, Windows Mobile 6.5.3, Windows CE.NET 4.1, Windows CE 5.0, Windows Embedded CE 6, you get the idea! Basically any device which supports .NET Compact Framework 2.0 or later will be able to use most of the functionality in the suite.
  • Better support for .NETCF 3.5 – By adding IEnumerable<T> interfaces to our collection classes you can write slightly simpler LINQ statements. Also we have implemented many features as Extension Methods. These can be used in either .NETCF 2.0 or 3.5 so long as you are using Visual Studio 2008 (The compiler in VS2005 doesn’t support these so you have to call them as static methods).
  • New InTheHand.Device.Location.dll library – This is modelled on the .NET 4.0 library and just this week it has been shown that Windows Phone 7 gets a version of the same library. By adding this support we’ve been able to completely re-design our GPS support and you can now write code with the same familiar object model on Windows 7, Windows Phone 7 and Windows Mobile and Windows Embedded CE. In the Evaluation version this shipped as InTheHand.Device.dll but for the full release we changed it to InTheHand.Device.Location.dll to match the Windows Phone 7 name, the namespaces and classes within the assembly are unchanged.
  • New InTheHand.Net.dll library – Previously this was released as a separate product but this now joins the suite and has had a number of new features including asynchronous versions of the WebClient methods, support for SMTP email sending, Remote Access (RAS) and some more classes in the NetworkInformation namespace. By integrating with the suite we have been able to share more functionality so for example our Visual Basic “My” extensions now have additional networking methods that are present in the full .NET framework.
  • InTheHand.WindowsMobile.Forms.ControlHelper.EnableVisualStyles – This extension method allows you to reskin all the supported controls on Windows Mobile 6.5.3 with their new themed versions.
  • InTheHand.WindowsMobile.Forms.Widget – On Windows Mobile 6.5 and later you can interrogate the widgets installed on the device. You can programmatically launch or uninstall Widgets too. There is a new sample application which shows a simple widget manager application.

 

For more information about Mobile In The Hand see the product page.

#    |
# Tuesday, January 26, 2010

Application and File Icons with Mobile In The Hand 4.0

There are a number of scenarios in which you want to retrieve the icon associated with a particular executable or other file type. One example is when building a file browser, you might also want to extract the icon associated with your application or another. The full .NET framework contains Icon.ExtractAssociatedIcon() for this very purpose. Mobile In The Hand includes a helper function to achieve the same result from the Compact Framework. Simply use the following code:-

  1. Icon i = IconHelper.ExtractAssociatedIcon(filePath);

filePath is the full path to any file. The icon will either be the icon associated with a particular file type or in the case of executables will be the embedded application icon (or a generic application icon if not present). The result is a regular System.Drawing.Icon type which you can draw using the Graphics class normally.

The documentation for the IconHelper class is available in the online library. For more information about Mobile In The Hand see the product page.

#    |
# Monday, January 04, 2010

Replacement for Type.GUID

A question came up on the newsgroups of how to get the Guid assigned to a Type via a GuidAttribute. Typically this will be defined when creating a manged Class/Interface to match a COM exposed CoClass/Interface. The desktop exposes a GUID property of the Type class. The workaround for the Compact Framework is fairly straight-forward and for convenience I have posted an amendment to my solution below in the form of an Extension method. This means that from your code you can achieve the desired result with Type.GetGUID() – which is as near as can be to the desktop syntax:-

  1. /// <summary>
  2. /// Extension method to get the GUID associated with the Type.
  3. /// </summary>
  4. /// <param name="t">the Type.</param>
  5. /// <returns>The GUID associated with the Type.</returns>
  6. public static Guid GetGUID(this Type t)
  7. {
  8.     Guid typeGuid = Guid.Empty;
  9.     object[] attributes = t.GetCustomAttributes(false);
  10.     foreach (object o in attributes)
  11.     {
  12.         if (o is GuidAttribute)
  13.         {
  14.             //has GuidAttribute - get the value
  15.             GuidAttribute ga = (GuidAttribute)o;
  16.             typeGuid = new Guid(ga.Value);
  17.         }
  18.     }
  19.  
  20.     return typeGuid;
  21. }

 

I have switched to using Live Writer for blog posts (no idea why I didn’t try it before) and it has much better support for code formatting especially with the “Paste as VS Code” plug-in.

#    |
# Wednesday, December 30, 2009

Email Configuration with Mobile In The Hand 4.0

One of the new items introduced in version 4.0 is a wrapper for the Email configuration provider. This provides a one-stop-shop to access and modify email account settings. This is used for all email account types except for Exchange synchronisation. Each account is identified by a unique Guid so to work with account settings you'll need to know this. This is exposed through a property of the EmailAccount object, for example the following code loops through all available EmailAccounts for which there is a unique ID (excludes the Exchange account).

foreach       (EmailAccount ea in os.EmailAccounts)

{

   if (ea.Properties[AccountProperty.UniqueStoreID] != null)

 

The UniqueStoreID is a Guid property and so can be cast to the Guid type (the Properties collection returns items of type object because it caters for all different types of properties).

Guid g = (Guid)ea.Properties[AccountProperty.UniqueStoreID];

The EmailAccountConfiguration class is located in InTheHand.WindowsMobile.Configuration.dll in the InTheHand.WindowsMobile.Configuration.Providers namespace. A new instance is created by passing the Guid into the constructor:-

InTheHand.WindowsMobile.Configuration.Providers.EmailAccountConfiguration eac = new InTheHand.WindowsMobile.Configuration.Providers.EmailAccountConfiguration(g);

Once created you have access to a number of properties which describe the account, you can change any of these and push your changes by calling the Update() method. Properties available include the incoming and outgoing servers, the ServiceType - either "POP3" or "IMAP4", DownloadDays (number of past days to download) and many more. The documentation for the class is available in the online library. For more information about Mobile In The Hand see the product page.

 

#    |
# Tuesday, December 22, 2009

Internet Connection Sharing with Mobile In The Hand 4.0

In Mobile In The Hand 4.0 all the Windows Mobile networking features are found in the InTheHand.WindowsMobile.Net assembly. This contains support for Connection Manager, Internet Sharing and Wireless Manager. This post will look at the Internet Sharing classes. Internet Sharing was introduced in Windows Mobile 5.0 AKU 3 but is generally associated with Windows Mobile 6. You can share an internet connection over a USB connection or over Bluetooth using the PAN (Personal Area Network) profile. To enable or disable a sharing session from your code you need only call a single method which looks like this:-

InTheHand.WindowsMobile.Net.InternetSharing.Enable(InTheHand.WindowsMobile.Net.SharingConnection.Bluetooth,"O2")

The first argument is a member of the SharingConnection enumeration which contains values for Bluetooth and Usb. The second argument is the name of the internet connection to use - this is the name of the GPRS connection which will be dialled. A simple Disable method exists to shut down the sharing connection:-

InTheHand.WindowsMobile.Net.InternetSharing.Disable()

You must remember to disable the connection once you have finished using it.

A full online library of class documentation for all this and more is available. For more information about Mobile In The Hand see the product page.

#    |
# Tuesday, December 15, 2009

More on "My" Functionality in Mobile In The Hand 4.0

In the last post on "My" functionality I showed you how to get started adding the My Extensions to your project. In this post I have assembled a detailed tree of all the "My" functionality added in Mobile In The Hand 4.0.

  • My
    • Application
      • Culture
      • Info
        • AssemblyName
        • CompanyName
        • Copyright
        • Description
        • DirectoryPath
        • ProductName
        • Title
        • Trademark
        • Version
      • UICulture
    • Computer
      • Audio
        • Play()
        • PlaySystemSound()
        • Stop()
      • Clipboard
        • Clear()
        • GetData()
        • GetDataObject()
        • GetImage()
        • GetText()
        • SetData()
        • SetDataObject()
        • SetImage()
        • SetText()
      • Clock
        • GmtTime
        • LocalTime
        • TickCount
      • FileSystem
        • CombinePath()
        • CopyDirectory()
        • CopyFile()
        • CreateDirectory()
        • DeleteDirectory()
        • DeleteFile()
        • Drives
        • FileExists()
        • GetDirectories()
        • GetDirectoryInfo()
        • GetDriveInfo()
        • GetFileInfo()
        • GetFiles()
        • GetName()
        • GetParentPath()
        • GetTempFileName()
        • MoveDirectory()
        • MoveFile()
        • OpenTextFileReader()
        • OpenTextFileWriter()
        • ReadAllBytes()
        • ReadAllText()
        • RenameDirectory()
        • RenameFile()
        • SpecialDirectories
          • CurrentUserApplicationData
          • MyDocuments
          • ProgramFiles
          • Programs
          • Temp
        • WriteAllBytes()
        • WriteAllText()
      • Info
        • AvailablePhysicalMemory
        • AvailableVirtualMemory
        • InstalledUICulture
        • OSPlatform
        • OSVersion
        • TotalPhysicalMemory
        • TotalVirtualMemory
      • Keyboard
        • SendKeys()
      • Name
      • Ports
        • OpenSerialPort()
        • SerialPortNames
      • Registry
        • ClassesRoot
        • CurrentUser
        • GetValue()
        • LocalMachine
        • SetValue()
      • Screen
    • User
      • Name

A full online library of class documentation for all this and more is available. For more information about Mobile In The Hand see the product page.

#    |
# Monday, December 14, 2009

Vibration and Profiles with Mobile In The Hand 4.0

One of the goals of the Mobile In The Hand library has always been to provide a consistent managed API regardless of which specific flavour of Windows Mobile device you are using. One example of this is using the Vibration feature used to alert the user. The APIs are completely different and so we have provided a simple managed API composing of just two static methods:-

InTheHand.WindowsMobile.Forms.Vibrate.Play();

System.Threading.Thread.Sleep(500);

InTheHand.WindowsMobile.Forms.Vibrate.Stop();

 

You generally won't want to vibrate the device for very long because it would be both annoying, and a battery drain. To avoid holding up your UI thread you can call the methods on a separate thread. Just remember you must call Stop() to turn off the vibration.

Another example of functionality which is implemented differently between touchscreen and non-touchscreen devices are Profiles. Standard Edition devices can feature a number of profiles for different scenarios, touch screen devices have just three - On, Vibrate only and Off. To retrieve all of the available profiles use the following code:-

 

foreach(string profile in InTheHand.WindowsMobile.Forms.MobileDevice.Profiles)

{

MessageBox.Show(profile);

}

You can set the device profile using a call to SetProfile:-

InTheHand.WindowsMobile.Forms.MobileDevice.SetProfile("Vibrate");

The name of the currently selected profile is available from the CurrentProfile property:-

MessageBox.Show(InTheHand.WindowsMobile.Forms.MobileDevice.CurrentProfile);

A full online library of class documentation for all this and more is available. For more information about Mobile In The Hand see the product page.

#    |
# Friday, December 11, 2009

Using Bluetooth Headsets with Mobile In The Hand 4.0

A commonly requested feature is the ability to switch audio to play through a Bluetooth headset device. Mobile In The Hand 4.0 brings this functionality to .NET Compact Framework developers allowing you to play any device audio through a paired headset device. It also includes classes to playback sounds too.

The AudioGateway sample application which ships with the library contains the functionality to playback a sound file and toggle between the device speaker and a headset. The code to perform the switch is incredibly simple:-

private   BluetoothAudioGateway bag = new BluetoothAudioGateway();

The BluetoothAudioGateway exists in the InTheHand.WindowsMobile.Media namespace. A CheckBox control toggles the output using the following code:-

private   void chkGateway_CheckStateChanged(object sender, EventArgs e)

{

 

   if (chkGateway.Checked)

   {

      bag.OpenAudio();

   }

 

   else

   {

      bag.CloseAudio();

   }

}

OpenAudio opens the connection to the headset and sends audio output to it. CloseAudio closes the connection and returns output to the built in speaker. The SoundPlayer class is used to play back a sound file:-

InTheHand.Media. SoundPlayer sp = new InTheHand.Media.SoundPlayer(txtFilename.Text);

sp.Play();

A full online library of class documentation for all this and more is available. For more information about Mobile In The Hand see the product page.

#    |
# Wednesday, December 09, 2009

Windows Mobile Provisioning using Mobile In The Hand 4.0

In the last post we saw the new My Extensions template which adds access to new Visual Basic features. In this post we will look at another new item introduced with Mobile In The Hand 4.0 - Provisioning XML. Visual Studio has a rich XML Editor built in, Windows Mobile uses provisioning XML documents for everything from adding a browser favourite through to configuring a new GPRS network. The new template allows you to quickly create an empty Provisioning XML document and includes the schema to ensure your document is valid. Let Visual Studio's Intellisense help you quickly build a provisioning document.

As with the Visual Basic example you start with an existing device project, in this case it can be either C# or Visual Basic. Select Add New Item and choose Provisioning XML from the list:-

In this example I have called the file AddFavourite.xml (no prizes for guessing what task we will be performing). The document is created with a skeleton provisioning document. Notice the namespace is provided which links to the schema we installed for you.

You can now add the required code between the wap-provisioningdoc tags. As you start to type the IntelliSense will suggest valid elements for you based on the schema:-

 

This makes it very easy to quickly build up a complete document:-

You can process a configuration document like this using the ConfigurationManager class. By setting the document as an embedded resource you can use the following code to load it and pass it to the ConfigurationManager:-

 

Dim xd As New System.Xml.XmlDocument

xd.Load(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("VisualBasicDeviceProject.AddFavourite.xml"))

InTheHand.WindowsMobile.Configuration.ConfigurationManager.ProcessConfiguration(xd, False)

After running this code you can check your Internet Explorer Mobile favourites:-

For more information about the library see the product page.

#    |
# Monday, December 07, 2009

New "My" Functionality in Mobile In The Hand 4.0

This blog post will walk through the process of adding the additional "My" functionality added in InTheHand.VisualBasic. To start off, open Visual Studio 2008 and create a new Visual Basic device project (or open an existing one). At this point you'll end up with a solution window which looks a bit like this. Note the inspired project name in this example:-

 

The next step is to right-click the project and select Add > New Item... from the menu:-

This will bring up the Add New Item window from which you should see MyExtensions among the list. Select this (you can change the default name if required) and click Add.

The new code file is added to the project. You don't need to edit this and you won't be interacting with it directly from your code. Your solution window will now look like this:-

 

You can now get on with building your application. Any time you start to type My you'll see a much longer list of options:-

Application, Computer and User are new items added by this library and provide additional functionality, all remaining a direct subset of the desktop experience. For example I added a button and in the Click handler added this simple code snippet:-

MessageBox.Show(

My.Application.Info.ProductName)

On running the code the Product Name is retrieved from the assembly information:-

 

In a future post I'll run through the various items available through the "My" syntax. For more information about the library see the product page.

#    |

Mobile In The Hand 4.0 Released

Today we put the final touches to Mobile In The Hand 4.0 and have released this latest version of the suite. This is a major reworking of the code and the library is now broken into 10 separate dlls so you only need to deploy the specific functionality you require in a project. We have also added some additional functionality alongside the code libraries themselves to add "My" keyword functionality for Visual Basic users and make it easier to incorporate and edit provisioning XML documents. Over the next few weeks I'll be posting a number of blog articles to highlight new features and elaborate on some of the less visible features.

Full details of the library are available on the product page.

#    |
# Monday, August 25, 2008

Get the name of your executing .exe

The Compact Framework doesn't support Assembly.GetEntryAssembly to determine the launching .exe. You can instead P/Invoke the native GetModuleFileName function like so:-

byte[] buffer = new byte[MAX_PATH * 2];

int chars = GetModuleFileName(IntPtr.Zero, buffer, MAX_PATH);

if (chars > 0)

{

string assemblyPath = System.Text.Encoding.Unicode.GetString(buffer, 0, chars * 2);

}

Where MAX_PATH is defined in the Windows CE headers as 260. The P/Invoke declaration for GetModuleFileName looks like this:-

[DllImport("coredll.dll", SetLastError = true)]

private static extern int GetModuleFileName(IntPtr hModule, byte[] lpFilename, int nSize);

The function expects a HMODULE - a handle to a native module. However passing IntPtr.Zero here indicates we want the module which created the process which is our .exe. This code will always return the path of the calling .exe regardless of if it is in a utility dll, or even a GAC assembly located in the \Windows folder.

#    |