Search code examples
c#windows-mobilepocketpc

process.Start causing Win32Exception on button push


I am trying to create a launcher app in C# for WINDOWS POCKET PC, the only programming language I know to make it. When I try to launch an external EXE in the same directory it throws an Win32Exception.

Here is the code:

using System;
using System.Diagnostics;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace app
{
    public partial class SMO2010 : Form
    {
        public SMO2010()
        {
            InitializeComponent();
        }

        private void 2010Image_Click(object sender, EventArgs e)
        {

        }

        private void PM_Click(object sender, EventArgs e)
        {

        }

        private void PMLabel_ParentChanged(object sender, EventArgs e)
        {

        }

        private void P_Click(object sender, EventArgs e)
        {

        }

        private void TMLauncher_Click(object sender, EventArgs e)
        {
            string str = "TextMaker.exe";
            Process process = new Process();
            process.StartInfo.FileName = "TextMaker.exe";
            process.Start();
        }
    }
}

The process.Start(); causes a Win32Exception. This is for Windows Mobile 2005.

Any suggestions?

EDIT: Here is the exception:

App.exe
Win32Exception

   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Launcher.Launcher_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
   at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
   at System.Windows.Forms.Application.Run(Form fm)
   at Launcher.Program.Main()

Solution

  • the exception does not say much. I assume it is simply by the application exe is not found. As you know, Windows CE 5 based system does not know a Current Directory and the search path for executables is limitted. Try with specifying the full path to TextMaker.exe, ie "\Programs\TextMaker\TextMaker.exe".

    It is very helpful in testing such executables from cmd line. Unfortunately, Windows CE PocketPC does not have a CLI. But there is the ITS Tools which provide a prun tool which can be used on a Connected device (ActiveSync, WMDC) to issue cmds to the device. In your case I would test with 'prun "TextMaker.exe"', which will not work and then with 'prun "\Programs\TextMaker\TextMaker.exe"', which should work, as long as TextMaker.exe is PocketPC compatible.