Created
June 28, 2016 09:32
-
-
Save martinwoodward/f5b195aa53b4ed52cabaf701486baa79 to your computer and use it in GitHub Desktop.
Example of PInvoke from Linux with .NET Core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices; | |
namespace PInvokeSamples { | |
public static class Program { | |
// Import the libc and define the method corresponding to the native function. | |
[DllImport("libc.so.6")] | |
private static extern int getpid(); | |
public static void Main(string[] args){ | |
// Invoke the function and get the process ID. | |
int pid = getpid(); | |
Console.WriteLine(pid); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@martinwoodward What is the alternative for following code:
This code i m using in Windows. I want alternate code for Linux(RHEL7).
`using System.Runtime.InteropServices;
namespace PInvokeSamples {
public static class Program {
}`