Garry Shutler
Garry Shutler

Reputation: 32698

How to determine the type of Windows Mobile device?

We have a Windows Mobile application which is currently running on Symbol (now Motorola) devices. We use the manufacturer's SDKs in order to do things like register barcode scans.

We now need to make the software work with Intermec devices.

I already have the scanning code abstracted behind an interface so all I need to do is wrap the Intermec APIs behind that interface and then load the correct version for the device in use.

However, I am having some difficulty in working out which type of device the software is running. I could just try loading the Symbol code and then when that fails try the Intermec code but that's rather rubbish.

Does anyone know how I can work out the type of device programmatically?

Upvotes: 0

Views: 1007

Answers (3)

Nick
Nick

Reputation: 3347

From http://www.christec.co.nz/blog/archives/77

Use the code below and call NativeMethods.GetOEMInfo()

private static class NativeMethods
{
  [DllImport("coredll.dll")]
  private static extern int SystemParametersInfo(uint uiAction, uint uiParam, StringBuilder pvParam, uint fWiniIni);

  private const uint SPI_GETPLATFORMTYPE = 257;
  private const uint SPI_GETOEMINFO = 258;

  private static string GetSystemParameter(uint uiParam)
  {
    StringBuilder sb = new StringBuilder(128);
    if (SystemParametersInfo(uiParam, (uint)sb.Capacity, sb, 0) == 0)
      throw new ApplicationException("Failed to get system parameter");
    return sb.ToString();
  }

  public static string GetOEMInfo()
  {
    return GetSystemParameter(SPI_GETOEMINFO);
  }

}

Upvotes: 0

Jared Miller
Jared Miller

Reputation: 893

This is native code but it works for me.

TCHAR buf[255];
SystemParametersInfo(SPI_GETOEMINFO, 255, &buf, NULL);

Then just parse the buffer to figure out which device it is.

Upvotes: -1

kgiannakakis
kgiannakakis

Reputation: 104198

See this link. It will help you get the OEM info of the device.

Upvotes: 2

Related Questions