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#
using System;
class GFG{
static public void Main()
{
bool process = false ;
process = Environment.Is64BitProcess;
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#
using System;
class GFG{
static public void Main()
{
bool process = false ;
process = Environment.Is64BitProcess;
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
Share your thoughts in the comments
Please Login to comment...