marshals string for unmanaged memory as ANSI.
using System; using System.Runtime.InteropServices; public class Starter { public static void Main() { int hProcess = API.GetModuleHandle(null); } } public class API { [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] public static extern int GetModuleHandle(string filename); }