Execute program

  • Thread starter Thread starter Francesco
  • Start date Start date
F

Francesco

Hello people!

I have a little problem
I have to write a program wich execute an other executable
program on wince device.

wich Comman i have to use ?

(I program with vb.net 2003 and have a symbol pdt2800
device with pocket pc2000)
 
What I did was a DllImport for the CreateProcess() API from coredll.dll :

using System;


public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 dwProcessId;
public Int32 dwThreadId;
}

public class Process
{
[System.Runtime.InteropServices.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,
IntPtr si,
ProcessInfo pi);

public static bool CreateProcess(String ExeName, String CmdLine)
{
ProcessInfo pi = new ProcessInfo();

return CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0, 0,
IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, pi) != 0;
}

}


This is the way I call the static method to, per esempio, start the notes
app to view a note:

Process.CreateProcess("\\Windows\\Notes",docFile);


-Dino
<Microsoft/>
 
This is a good example. I was wondering if it would be
possible to wait for or be notified of the created process'
completion.

TIA,
Tom.
-----Original Message-----
What I did was a DllImport for the CreateProcess() API from coredll.dll :

using System;


public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 dwProcessId;
public Int32 dwThreadId;
}

public class Process
{
[System.Runtime.InteropServices.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,
IntPtr si,
ProcessInfo pi);

public static bool CreateProcess(String ExeName, String CmdLine)
{
ProcessInfo pi = new ProcessInfo();

return CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0, 0,
IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, pi) != 0;
}

}


This is the way I call the static method to, per esempio, start the notes
app to view a note:

Process.CreateProcess("\\Windows\\Notes",docFile);


-Dino
<Microsoft/>

Francesco said:
Hello people!

I have a little problem
I have to write a program wich execute an other executable
program on wince device.

wich Comman i have to use ?

(I program with vb.net 2003 and have a symbol pdt2800
device with pocket pc2000)


.
 
Do a P/Invoke of WaitForSingleObject() on the process handle (don't forget
to CloseHandle() on it before you leave, too). That will wait until the
process exits before allowing the thread to continue.

Paul T.

Tom Dorgan said:
This is a good example. I was wondering if it would be
possible to wait for or be notified of the created process'
completion.

TIA,
Tom.
-----Original Message-----
What I did was a DllImport for the CreateProcess() API from coredll.dll :

using System;


public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 dwProcessId;
public Int32 dwThreadId;
}

public class Process
{
[System.Runtime.InteropServices.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,
IntPtr si,
ProcessInfo pi);

public static bool CreateProcess(String ExeName, String CmdLine)
{
ProcessInfo pi = new ProcessInfo();

return CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0, 0,
IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, pi) != 0;
}

}


This is the way I call the static method to, per esempio, start the notes
app to view a note:

Process.CreateProcess("\\Windows\\Notes",docFile);


-Dino
<Microsoft/>

Francesco said:
Hello people!

I have a little problem
I have to write a program wich execute an other executable
program on wince device.

wich Comman i have to use ?

(I program with vb.net 2003 and have a symbol pdt2800
device with pocket pc2000)


.
 
http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=251

Tom Dorgan said:
This is a good example. I was wondering if it would be
possible to wait for or be notified of the created process'
completion.

TIA,
Tom.
-----Original Message-----
What I did was a DllImport for the CreateProcess() API from coredll.dll :

using System;


public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 dwProcessId;
public Int32 dwThreadId;
}

public class Process
{
[System.Runtime.InteropServices.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,
IntPtr si,
ProcessInfo pi);

public static bool CreateProcess(String ExeName, String CmdLine)
{
ProcessInfo pi = new ProcessInfo();

return CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0, 0,
IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, pi) != 0;
}

}


This is the way I call the static method to, per esempio, start the notes
app to view a note:

Process.CreateProcess("\\Windows\\Notes",docFile);


-Dino
<Microsoft/>

Francesco said:
Hello people!

I have a little problem
I have to write a program wich execute an other executable
program on wince device.

wich Comman i have to use ?

(I program with vb.net 2003 and have a symbol pdt2800
device with pocket pc2000)


.
 
Back
Top