I am listing all running processes in system with it full path. My application is running fine in XP but in vista, it gives access denied exception while accessing MainModule.FileName. (Due to UAC, i think).
foreach (Process process in Process.GetProcesses())
{
sProcess = process.ProcessName;
sFullpath = process.MainModule.FileName;
..
..
..
}
I did not find a solution to deal with UAC. Any clue??
It may not be UAC at all. It may be that your process is x32 and the process being queried is x64 or vice versa. process.MainModule seems to choke when that happens with a Win32Exception, “Only part of a ReadProcessMemory or WriteProcessMemory request was completed”
Could that be it?