Thursday, March 12, 2009

Get Application Execution path in .NET

Desktop Application


Windows Mobile Application C#

You should import using System.Reflection
using System.Reflection;

Assembly asm = Assembly.GetExecutingAssembly();
String path = "";
path= System.IO.Path.GetDirectoryName(asm.GetName().CodeBase);

How to Access Internet through Windows Mobile Emulator

To Access the web through your mobile emulater First of all you have to install Microsoft ActiveSync. 

  •  Then close all running Mobile Emulators.
  •  Then run ActiveSync. (you can run it also using taskbar icon)
  •  Then Goto File Menu --> Connection Settings, and change settings as 
  • Then Open Visual Studio, In there goto Tools --> Device Emulator manager and select the pertivular emulator.
  • In Device Emulator Go to Action Menu and Select Connect.
  • And cradle.
  • Now you can see Microsft Active Sync status changing to connected..
  • .. now go to the web using your emulator.

Wednesday, March 11, 2009

Disable Windows Mobile Clock Access

To restrict windows mobile key access they are main two methods.

  1.  You can replace the clock.exe in the window folder by empty application.
  2.  You can change some registry values to prevent opening the clock. I will show how we can use C# to do it
 using Microsoft.Win32; 
 // import  Microsoft.Win32 top of the class file

 Dissable the clock

RegistryKey hklm = Registry.LocalMachine;
hklm = hklm.OpenSubKey(@"\Software\Microsoft\Clock\", true);

System.Byte[] offValue = new byte[1];
offValue[0] = 0x30;
hklm.SetValue("AppState", offValue);

Enable the clock

 RegistryKey hklm = Registry.LocalMachine;
 hklm = hklm.OpenSubKey(@"\Software\Microsoft\Clock\", true);

System.Byte[] offValue = new byte[1];
offValue[0] = 0x11;
hklm.SetValue("AppState", offValue);

Friday, March 6, 2009

Get and Compare the Control

Some of the time we need to know what kind ok control are we dealing with. This simple example mimics how to know what is our control.

As an example say we want to go through the form’s controls and show a message if there were a text box.

foreach (Control n in this.Controls) {

String tp = "System.Windows.Forms.TextBox";

   if (n.GetType().ToString() ==tp){

         // Do something