c sharp

Environment.Is64ButProcess Property

Running the C# programs are very simple and clear to predict the output. In some cases, we need to know the process that is running in our machine. The Environment class in C# tells which process is running in our system using the Is64BitProcess Property.

Now, we will discuss that property in detail.

Environment.Is64BitProcess

This property is available in the Environment Class. It provides information about the working environment like variables, methods used, and system related information in C#.

The Is64BitProcess is a property in C# Environment Class that is used to check the process that is running in our machine.

If the process that is running in our machine is a 64-bit process, the Boolean value – True – is returned. Otherwise, it returns False.

This property can be applied in the .NET 2.0,2.1,3.0.3.1 and 6.7.

Syntax:

bool Is64BitProcess

Let’s see the following examples to understand the concept better.

Example 1:

Check your process using the previous property.

Explanation:

Line 01: We use the System library for using the Console.WriteLine() and the other statements in our code.

Line 03: We create a class named Linuxhint after.

Line 05: The main() method starts from here.

Line 09: Console.WriteLine(Environment.Is64BitProcess);

Inside the main() method, we check the running process using the Is64BitProcess property.

Finally, the output is True.

Example 2:

We can make the previous code in a more precise way. Just add the conditional statements to display the output with a message.

Explanation:

Line 01: We use the System library for using the Console.WriteLine() and the other statements in our code.

Line 03: We create a class named Linuxhint after.

Line 05: The main() method starts from here.

Line 08: if(Environment.Is64BitProcess==true)

Inside the main method(), we check if the process is a 64-bit process using the Is64BitProcess property inside the “if” condition.

If this becomes true, the following message is displayed by executing the Console statement:

Console.WriteLine(“The Process running in our current system is 64-bit process”);

Line 14: Otherwise, it goes to the else block and executes the Console statement at Line 17.

Line 17: Console.WriteLine(“The Process running in our current system is 64-bit process”);

Finally, the output is The Process running in our current system is 64-bit process which means that the process running in our system is a 64-bit process (If block is executed).

Conclusion

At the end of this article, we came to know that it is possible to check if the process that is running in our machine is a 64-bit or not using the Is64BitProcess Property. If the process that is running in our machine is a 64-bit process, the Boolean value – True – is returned. Otherwise, it returns False. We can apply this property in the .NET 2.0,2.1,3.0.3.1 and 6.7 versions.

About the author

Gottumukkala Sravan Kumar

B tech-hon's in Information Technology; Known programming languages - Python, R , PHP MySQL; Published 500+ articles on computer science domain