Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C# Program to Check Whether Running Process is 64-bit Process or Not Using Environment Class

  • Last Updated : 01 Nov, 2021

Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since last system boot in milliseconds information. In this article, we can check which process is running in our system using the Is64BitProcess property of the Environment Class. This method is used to check whether the current process is the 64-bit process or not. If the current process is a 64-bit process then it will return true otherwise it will return false. 

Syntax:

Environment.Is64BitProcess

Return Type: The return type of this property is boolean. It will return true if the process is a 64-bit process. Otherwise, return false.

Example 1:



In this example, we are running our code on a 64-bit machine.

C#




// C# program to determine whether the given 
// process is 64-bit process or not. Using 
// Is64BitProcess process of Environment Class
using System;
  
class GFG{
      
static public void Main()
{
      
    // Declare a boolean variable and set to false
    bool process = false;
      
    // Set the method to the initialized variable
    process = Environment.Is64BitProcess;
      
    // Check whether the current process 
    // is 64-bit process or not
    if (process == true)
        Console.WriteLine("The current process is 64-bit process");
    else
        Console.WriteLine("The current process is not 64-bit process");
}
}

Output:

The current process is 64-bit process

Example 2:

In this example, we are running the same code on a 32-bit machine and we get a different output because now the process is 32-bit.

C#




// C# program to determine whether the given 
// process is 64-bit process or not. Using 
// Is64BitProcess process of Environment Class
using System;
  
class GFG{
      
static public void Main()
{
      
    // Declare a boolean variable and set to false
    bool process = false;
      
    // Set the method to the initialized variable
    process = Environment.Is64BitProcess;
      
    // Check whether the current process 
    // is 64-bit process or not
    if (process == true)
        Console.WriteLine("The current process is 64-bit process");
    else
        Console.WriteLine("The current process is not 64-bit process");
}
}

Output:

The current process is not 64-bit process




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!