您可以用CoreDll.DLL中的CreateProcess()函数。下面是转载自microsoft.public.dotnet.framework.compactframework讨论组的一段例子代码: using System;
using System.Runtime.InteropServices;
//... class ExecSample
{
public class 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 cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );
[DllImport("CoreDll.dll")]
private extern static Int32 GetLastError();
public static bool CreateProcess( String ExeName, String CmdLine, ProcessInfo pi )
{
if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
return CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0, 0, IntPtr.Zero, IntPtr.Zero, si, pi) != 0;
}
public static void Main()
{
String progPath = "Calc.exe";
Console.WriteLine("Launching \"{0}\"...", progPath);
ProcessInfo pi = new ProcessInfo();
if ( CreateProcess(progPath, "", pi) )
Console.WriteLine("Success! (pid = {0})", pi.ProcessId.ToString());
else
Console.WriteLine("Failed (system error = {0})", GetLastError().ToString());
}
}希望能够对您有帮助。
Hogwarts - S(u)ddenly dis@ppeared...
-
本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
using System.Runtime.InteropServices;
//... class ExecSample
{
public class 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 cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );
[DllImport("CoreDll.dll")]
private extern static Int32 GetLastError();
public static bool CreateProcess( String ExeName, String CmdLine, ProcessInfo pi )
{
if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
return CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0, 0, IntPtr.Zero, IntPtr.Zero, si, pi) != 0;
}
public static void Main()
{
String progPath = "Calc.exe";
Console.WriteLine("Launching \"{0}\"...", progPath);
ProcessInfo pi = new ProcessInfo();
if ( CreateProcess(progPath, "", pi) )
Console.WriteLine("Success! (pid = {0})", pi.ProcessId.ToString());
else
Console.WriteLine("Failed (system error = {0})", GetLastError().ToString());
}
}希望能够对您有帮助。
Hogwarts - S(u)ddenly dis@ppeared...
-
本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货