private static unsafe string[] GetCommandLineArgsNative() { char *lpCmdLine = Interop.Kernel32.GetCommandLine(); Debug.Assert(lpCmdLine != null); int numArgs = 0; char **argvW = Interop.Shell32.CommandLineToArgv(lpCmdLine, &numArgs); if (argvW == null) { ThrowHelper.ThrowOutOfMemoryException(); } try { string[] result = new string[numArgs]; for (int i = 0; i < result.Length; i++) { result[i] = new string(*(argvW + i)); } return(result); } finally { Interop.Kernel32.LocalFree((IntPtr)argvW); } }