I have used PInvoke to call CreateProcess. Most of the parameters are
required to be null in CE, so it's pretty easy. Here's a C# example.
public struct PROCESS_INFORMATION
{
public UInt32 hProcess;
public UInt32 hThread;
public UInt32 dwProcessId;
public UInt32 dwThreadId;
}
[DllImport("coredll.dll", EntryPoint="CreateProcess", SetLastError=true)]
private static extern int CreateProcess(
string lpszImageName,
string lpszCmdLine,
IntPtr lpsaProcess, // null
IntPtr lpsaThread, // null
int fInheritHandles, //false
uint fdwCreate, // I don't use this parameter. It could be made available
as a bitwise enum ...
IntPtr lpvEnvironment, // null
IntPtr lpszCurDir, // null
IntPtr lpsiStartInfo, // null
ref PROCESS_INFORMATION lppiProcInfo
);
// public wrapper doesn't expose the mandatory parameters
public static int CreateProcess(
string lpszImageName,
string lpszCmdLine
ref PROCESS_INFORMATION lppiProcInfo;
)
{
if(lpszImageName != null)
{
if(!lpszImageName.EndsWith("\0"))
{
lpszImageName += "\0";
}
}
if(lpszCmdLine != null)
{
if(!lpszCmdLine.EndsWith("\0"))
{
lpszCmdLine += "\0";
}
}
return CreateProcess(
lpszImageName,
lpszCmdLine,
IntPtr.Zero, // null
IntPtr.Zero, // null
0, //false
0, // I don't use this parameter ...
IntPtr.Zero, // null
IntPtr.Zero, // null
IntPtr.Zero, // null
ref lppiProcInfo
);
}
}