我需要在单声道应用程序中通过PInvoke调用此过程。 请来图书馆的名字。
答案 0 :(得分:2)
作为GNU C lib的一部分,它位于libc
:
using System;
using System.Runtime.InteropServices;
namespace posix
{
class MainClass
{
[DllImport ("libc", SetLastError=true)]
private static extern int system (string exec);
[DllImport ("libc", SetLastError=true)]
public static extern int execv (string path, string[] argv);
public static void Main (string[] args)
{
Console.WriteLine ("Error:{0}", system ("ls -l"));
Console.WriteLine ("Error:{0}", execv ("/usr/bin/vi", new string[] { "/usr/bin/vi" , "foobar.txt" }));
// Of course, being execv without failure we never come back...
Console.WriteLine ("Should never be displayed");
Console.WriteLine ("Error:{0}", Mono.Unix.Native.Syscall.execv ("/usr/bin/ls", new string[] { "/usr/bin/ls" }));
}
}
}