// Get the current process. public static Process GetCurrentProcess() { lock (typeof(Process)) { if (currentProcess == null) { currentProcess = new Process(); int processID; IntPtr processHandle; GetCurrentProcessInfo (out processID, out processHandle); currentProcess.processID = processID; currentProcess.processHandle = processHandle; currentProcess.argv = Environment.GetCommandLineArgs(); if (currentProcess.argv != null && currentProcess.argv.Length > 0) { ProcessStartInfo info = new ProcessStartInfo(); info.FileName = currentProcess.argv[0]; info.Arguments = ProcessStartInfo.ArgVToArguments (currentProcess.argv, 1, " "); currentProcess.startInfo = info; } } return(currentProcess); } }