Compact framework 1.1

Hi, I'm trying to spin off a new process by doing something like this:

ProcessStartInfo s = new ProcessStartInfo(ExeName);

s.Arguements = CmdLine;

Process.Start(s);

I have included the proper using directives that msdn said, and the types are fine in a windows enviroment, but when I use it on Compact Framework 1.1 it isn't recognized, is there something similar I can use to create a new thread, I cannot update this device to CF 2.0




Answer this question

Compact framework 1.1

  • Mr.Analogy

    ahmedilyas wrote:

    moved thread to appropriate forum

    I don't think you can do this in .NET CF 1.0 (there was no 1.1), but only in .NET CF 2.0

    You may have to PInvoke, Create a process using CreateProcess()

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/wcecoreos5/html/wce50lrfcreateprocess.asp

    Thats actually the first thing I tried:

    I first created a structure:

    public class ProcessInfo

    {

    public IntPtr hProcess;

    public IntPtr hThread;

    public Int32 ProcessId;

    public Int32 ThreadId;

    }

    then did the imports

    [DllImport("CoreDll.DLL", SetLastError = true)]

    private extern static int CreateProcess(String imageName, String cmdLine,

    IntPtr lpProcessAttributes, IntPtr lpThreadAttributes,

    Int32 boolInheritHandles, Int32 dwCreationFlags,

    IntPtr lpEnvironment, IntPtr lpszCurrentDir,

    Byte[]bArray, ProcessInfo pi);

    then in the function:

    ProcessInfo pi = new ProcessInfo();

    if (File.Exists(ExeName))

    {

    if (CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,

    0, 0, IntPtr.Zero, IntPtr.Zero, new byte[128], pi) == 0)

    {

    int i = Marshal.GetLastWin32Error();

    EditText("Errror2: " + i.ToString());

    return 42;

    }

    }

    This gives me an error code 126, Module cannot be found



  • Ji Zhang [MSFT]

    Process does not exist in .NET CF 1.0

    as for the error on not finding the module, could be because the exefilename/path is incorrect.

    are you able to post the code you used to PInvoke (which you have), including the method you call it giving it the arguments/parameters



  • DavidThi808

    moved thread to appropriate forum

    I don't think you can do this in .NET CF 1.0 (there was no 1.1), but only in .NET CF 2.0

    You may have to PInvoke, Create a process using CreateProcess()

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/wcecoreos5/html/wce50lrfcreateprocess.asp

     



  • david2929

    Where is the code you are calling from

  • Kallex

    int ProcessReturn = CreateProcess("\\Bin\\ProcTest.exe" , "-f \\Result\\result.txt");

    That is where is it called,

    And this is the complete function

    public int CreateProcess(String ExeName, String CmdLine)

    {

    EditText("CmdLine: " + CmdLine);

    ProcessInfo pi = new ProcessInfo();

    if (File.Exists(ExeName))

    {

    if (CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,

    0, 0, IntPtr.Zero, IntPtr.Zero, new byte[128], pi) == 0)

    {

    int i = Marshal.GetLastWin32Error();

    EditText("Errror2: " + i.ToString());

    return 42;

    }

    }

    else

    return 42;

    WaitForSingleObject(pi.hProcess, 2000000);

    Int32 exitCode;

    if (GetExitCodeProcess(pi.hProcess, out exitCode) == 0)

    {

    CloseHandle(pi.hThread);

    CloseHandle(pi.hProcess);

    return 42;

    }

    CloseHandle(pi.hThread);

    CloseHandle(pi.hProcess);

    return exitCode;

    }



  • lax4u

    'Error 1 The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly reference ) '

    Which using directive did you use for that code That is the same error I got with the code I posted earlier only the typename was different



  • Greenstrike

    I have this code working in CF 1.0:

    [DllImport("coredll.Dll")]
    private static extern int CreateProcess(string strImageName, string strCmdLine, IntPtr pProcessAttributes, IntPtr pThreadAttributes, int bInheritsHandle, int dwCreationFlags, IntPtr pEnvironment, IntPtr pCurrentDir, Byte[] bArray, ProcessInfo oProc);

    private void LaunchWeb(string url)
    {
    ProcessInfo pi = new ProcessInfo();
    CreateProcess(
    "iexplore.exe", url, IntPtr.Zero, IntPtr.Zero, 0, 0, IntPtr.Zero, IntPtr.Zero, new Byte[128], pi);
    }

    public class ProcessInfo
    {
    public int Process;
    public int Thread;
    public int ProcessID;
    public int ThreadID;
    }



  • MHGameWork

     ahmedilyas wrote:

    Process does not exist in .NET CF 1.0

     

    as for the error on not finding the module, could be because the exefilename/path is incorrect.

    are you able to post the code you used to PInvoke (which you have), including the method you call it giving it the arguments/parameters

     

    this is the PInvoke

    DllImport("CoreDll.DLL", SetLastError = true)]

    private extern static int CreateProcess(String imageName, String cmdLine,

    IntPtr lpProcessAttributes, IntPtr lpThreadAttributes,

    Int32 boolInheritHandles, Int32 dwCreationFlags,

    IntPtr lpEnvironment, IntPtr lpszCurrentDir,

    Byte[]bArray, ProcessInfo pi);

     

    The Path is correct that was one of the first things I checked



  • NickNotYet

    I recommend you to use OpenNET Compact Framework library - see http://www.opennetcf.org - the source code is still available free to download till the version 1.4 - link here. See OpenNETCF.Diagnostics namespace.



  • DadUnit

    This works for me in 1.1:

    Process proc = new Process();
    proc.StartInfo = new ProcessStartInfo(myExe, exeArgs);
    proc.Start();



    but what you have looks like it should work also. what do you mean by 'isn't recognized'.

  • Compact framework 1.1