How to capture information from a 64-bit process that is running?

2

Well, I need help in capturing information from a running process. I can accomplish this task by accessing mainmodule of 32-bit processes, however, I can not do the same with 64-bit processes. I do not know if the reason is I'm trying to access such information through a 32-bit application. I can access the mainmodule of 64-bit processes, however, the return is null.

foreach (Process clsProcess in Process.GetProcesses())
        {
            //Capturando a descrição de um processo em execução
            string nomeProd = clsProcess.MainModule.FileVersionInfo.FileDescription.ToString();
        }

As said, it works perfectly on a 32-bit computer, as it does not contain 64-bit programs. However, I am developing the application for both types (32 and 64), and I need help to capture the information in a 64-bit process.

    
asked by anonymous 01.07.2016 / 08:02

2 answers

2

How about generating a 64-bit application and being happy like that? This is the most appropriate solution.

If you still want to continue in 32 bits and you just do not want the error to stop the application, just catch the Win32Exception exception. It will take 32-bit processes and ignore the 64 bits.

In general, you need administrator privilege to perform this. You still will not have access to all processes, this is normal, so capturing this exception is important.

There is a answer in the OS that uses the Windows API directly and can help. I do not know if it helps.

There is a SO solution written in VB.Net using System.Management which can help too.

I hope this will at least give way.

    
01.07.2016 / 12:33
0

If your application is written in managed code, it can be compiled to "Any CPU", so it will behave according to the operating system running. You will get process information running in 32-bit and 64-bit.

    
01.07.2016 / 18:08