Access denied an exception while accessing process.MainModule.FileName

I list all running processes in the system with the full path. My application works fine in XP, but in Vista, it provides access to a prohibited exception when 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 work with UAC. Any hint

+3
source share
3 answers

It cannot be UAC at all. Perhaps your process is x32 and the requested process is x64 or vice versa. process.MainModule seems to suffocate when this happens with Win32Exception: "Only part of the ReadProcessMemory or WriteProcessMemory request is executed"

Could it be?

+2
source

Windows 7 Vista , win api, .

:

.Net

+1

DJA, Process.MainModule API EnumProcessModules:

DLL, EnumProcessModules

, , , ERROR_PARTIAL_COPY (299).

0
source

Source: https://habr.com/ru/post/1723453/