Start an extern application




I'm trying, via my code in C#, to start an extern application. I've
tried to following code without success :

public struct ProcessInfo
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;

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

private extern static int CreateProcess(String imageName, String
IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, Int32
Int32 dwCreationFlags, IntPtr lpEnvironment, IntPtr lpszCurrentDir,
byte [] si, ProcessInfo pi );

ProcessInfo pi = new ProcessInfo();
byte [] si = new byte[128];

int process = CreateProcess("", @"\Windows\TheApplication.exe",
IntPtr.Zero, 0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);

I end up with a NotSupportedException.
Thanks for all the hints you could give me...

Paul G. Tobey [eMVP]

ProcessInfo is data that's returned from CreateProcess. Given that, your
declaration is wrong. The pi item should be 'ref'. Further, the si
parameter is really a pointer and it should be set to NULL, so change your
declaration to take an IntPtr and pass IntPtr.Zero.

You can look at OpenNETCF and see how we declared CreateProcess().

Paul T.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question