Windows Mobile Development

From OptiWiki

Jump to: navigation, search


Contents

When deploying an application, I get "Connect to device failed". Reconnecting the device does not work!

This is caused by the Device Connectivity Component, also known as ActiveSync. Start the Windows Task manager, and end the process called wcescomm.exe.
now, start ActiveSync from your start menu again, and see if this works. If not, close the IDE, and start it again.

I want to implement things like capturing hardware buttons, making phone calls, and so on in C#

This can be done using P/Invoke and CoreDll.dll. A full functional sample shows how to do this.

I want to capture the customer's signature

This can be done using an Example solution from Microsoft.

I want to use GPS location data in my own application

There are 2 ways to do this.

1. You can open a serial port (serial port info H19), and do the calculations yourself in your application (or use a component like OpenNetCF.IO.Serial to do this)
2. You can use the GPSApi.dll to do this. Microsoft provides a sample application together with the Compact Framework which shows you how to do that. This demo is most likely located in C:\Program Files\Windows Mobile 6 SDK\Samples\Smartphone\CS\GPS on your Windowx XP system. Please note that the "External GPS" utility should be configured, or at least, the Hardware tab of this utility should be configured.

I want to send an SMS message using my own application

This can easy be done using Microsoft's SmsMessage class.
This class can be used in the following way:

  public void SendSMS(string _to, string _msg)
  {
      Microsoft.WindowsMobile.PocketOutlook.SmsMessage _message = new Microsoft.WindowsMobile.PocketOutlook.SmsMessage();        
 
      try    
      {    
          _message.To.Add(new Microsoft.WindowsMobile.PocketOutlook.Recipient("+31612345678 begin_of_the_skype_highlighting              +31612345678      end_of_the_skype_highlighting begin_of_the_skype_highlighting              +31612345678      end_of_the_skype_highlighting begin_of_the_skype_highlighting              +31612345678      end_of_the_skype_highlighting begin_of_the_skype_highlighting              +31612345678      end_of_the_skype_highlighting begin_of_the_skype_highlighting              +31612345678      end_of_the_skype_highlighting begin_of_the_skype_highlighting              +31612345678      end_of_the_skype_highlighting begin_of_the_skype_highlighting              +31612345678      end_of_the_skype_highlighting begin_of_the_skype_highlighting              +31612345678      end_of_the_skype_highlighting");//phone nbr     
          _message.Body = "Your message body";
          _message.Send();    
      }  
      catch (SmsException) 
      {
          MessageBox.Show("SMS SEND FAILED", "SMS FAIL");
          return;
      } 
      MessageBox.Show("SMS SENT", "SMS SUCCESS");
  }

I want any connection (e.g. GPRS) to be established as soon as I need it in my application.

You can do this by the use of the Connection manager API of Microsoft:
Pages explaining the Connection manager

You can also use the Smart Device Framework of OpenNETCF. The connectionmanager.CS is added to this framework.

I want to be able to enable or disable WLAN, GSM or Bluetooth from source.

This can be done using the code from this forum. The C++ code is on there, as well as a C# wrapper.

I want to monitor the GSM signal strength!

This can be done using the TAPI of Microsoft. In particular the LINEDEVSTATUS is important.

I want to use a unique ID of the PDA!

Please check on the MSDN site for a way to do this on Windows Mobile devices.
You will be able to determine the brand of the device, as well as a unique ID of it. The unique ID is determined by the hardware.

I want to let the PDA vibrate

To control the vibrate function of the PDA, you can use the following code:

  NLED_SETTINGS_INFO ledSet;
  memset(&ledSet, 0, sizeof(ledSet));
  ledSet.LedNum = 2; // vibrate
  ledSet.OffOnBlink = 1; // on
  NLedSetDevice(NLED_SETTINGS_INFO_ID, &ledSet);
  Sleep(300);
  ledSet.OffOnBlink = 0; // off
  NLedSetDevice(NLED_SETTINGS_INFO_ID, &ledSet);

I want to retrieve the WLAN MAC Address

There are two ways to retrieve the MAC address, one is through a registry key, the other is to retrieve it from the adapter info.

  1. The registry key is at [HKLM\Comm\<adaptername>\Parms\MACAddress]
  2. The function to retrieve the adapter info is GetAdapterInfo()

The adaptername for the H 19 is "SWLD246L1".

The registry key will be present after the WLAN module has been powered on. From that moment on this registry key will stay present, even if the adapter is turned off.

The GetAdapterInfo() will only work when the WLAN module is turned on.


How can I use Java applications on my device?

If your device does not include a pre-installed Java Virtual Machine, you can use a third party one, such as CrEme.

Views
Personal tools