managed

Possible to call C++ code from C#?

大兔子大兔子 提交于 2019-11-26 00:36:50
问题 Is it possible to call C++ code, possibly compiled as a code library file (.dll), from within a .NET language such as C#? Specifically, C++ code such as the RakNet networking library. 回答1: One easy way to call into C++ is to create a wrapper assembly in C++/CLI. In C++/CLI you can call into unmanaged code as if you were writing native code, but you can call into C++/CLI code from C# as if it were written in C#. The language was basically designed with interop into existing libraries as its

How to get parent process in .NET in managed way

痞子三分冷 提交于 2019-11-25 22:34:24
问题 I was looking a lot for method to get parent process in .NET, but found only P/Invoke way. 回答1: This code provides a nice interface for finding the Parent process object and takes into account the possibility of multiple processes with the same name: Usage: Console.WriteLine("ParentPid: " + Process.GetProcessById(6972).Parent().Id); Code: public static class ProcessExtensions { private static string FindIndexedProcessName(int pid) { var processName = Process.GetProcessById(pid).ProcessName;