Development

C# code to soft reset a Windows Mobile device

Here is the C# code to soft reset a Windows Mobile device (using P/Invoke) [DllImport(“coredll.dll”, SetLastError = true)] static extern int SetSystemPowerState(string psState, int StateFlags, int Options); const int POWER_FORCE = 4096; const int POWER_STATE_RESET = 0x00800000; private void SoftReset() { SetSystemPowerState(null, POWER_STATE_RESET, POWER_FORCE); } Share this:

Read More

How to get information about softwares installed on Windows Mobile devices?

Best method is to ask the configuration service provider (CSP). Step 1: Add Reference to Microsoft.WindowsMobile.Configuration Step 2: Add the following statements at the top of the c# code file. using System.Xml; using Microsoft.WindowsMobile.Configuration; Step 3: Prepare a csp string (xml format) and pass it to ProcessConfiguration method of ConfigurationManager. Return value is the xml…

Read More

How to disable "Unsigned Prompt Policy" on Windows Mobile?

Many Windows Mobile (Pocket PC) devices ship with one-tier security configuration enabled. That means if an unsigned application is started, then the user is prompted whether to allow the unsigned application to run or not. If the user based on his/her judgment allows the application to run, the application runs in privileged mode whereby it…

Read More

How to disable “Unsigned Prompt Policy” on Windows Mobile?

Many Windows Mobile (Pocket PC) devices ship with one-tier security configuration enabled. That means if an unsigned application is started, then the user is prompted whether to allow the unsigned application to run or not. If the user based on his/her judgment allows the application to run, the application runs in privileged mode whereby it…

Read More

How to get process id and thread id from a Window Handle in .NET CF?

Specify the namespace for doing P/Invoke stuff i.e. calling Win32 API functions from managed code. using System.Runtime.InteropServices; GetWindowThreadProcessId Win32 function retrieves the identifiers of the process and thread that created the specified window. Here is how we declare GetWindowThreadProcessId for use in managed code (c#). [DllImport(“coredll.dll”)] private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);…

Read More

Writing "Hello World" program for Windows Phone 7

Windows Phone 7 (WP7) is a cool new mobile platform from Microsoft. Developers can use Silverlight, XNA Framework and of course .NET compact framework for developing applications for WP7. What do you need To get started, download and install the following tools on your Windows 7 or Vista PC. http://www.microsoft.com/downloads/details.aspx?FamilyId=2338b5d1-79d8-46af-b828-380b0f854203&displaylang=en Installation includes Visual Studio 2010,…

Read More

Writing “Hello World” program for Windows Phone 7

Windows Phone 7 (WP7) is a cool new mobile platform from Microsoft. Developers can use Silverlight, XNA Framework and of course .NET compact framework for developing applications for WP7. What do you need To get started, download and install the following tools on your Windows 7 or Vista PC. http://www.microsoft.com/downloads/details.aspx?FamilyId=2338b5d1-79d8-46af-b828-380b0f854203&displaylang=en Installation includes Visual Studio 2010,…

Read More

No Application.StartupPath in .NET CF! There is a solution though…

Too bad there is no straight-forward way in net CF for an application to determine its folder path from where it was launched. But following code works just fine. string assembly = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; string currentFolderPath = System.IO.Path.GetDirectoryName(assembly); Enjoy… Share this:

Read More

Simulating key presses in your program with keybd_event function

Out of need or curiosity you might want to know how to send key presses from your native application. The core of the solution involves calling keybd_event() function which has the following prototype. VOID keybd_event(BYTE bVk, BYTE bScan, DWORD dwFlags, DWORD dwExtraInfo); bVk is the virtual-key code of the character. bScan is the hardware scan…

Read More