Getting Windows Build Number programmatically [duplicate] - c#

This question already has answers here:
Getting Windows OS version programmatically
(6 answers)
Closed 5 years ago.
Using C#, how can I get the Windows build number or OS Build number as shown in the About window? This is different from the version number: for Windows 10 Creator Update, the Build Number would be 1703 and the OS Build would be 15063.296.
I can't find anything relevant in Environment.OSVersion and this linked question (Getting Windows OS version programmatically) is only about getting the version number (10 in this case)

The following gets the Build number:
Environment.OSVersion.Version.Build

Related

API to know the amount of free stoarge space on my windows device [duplicate]

This question already has answers here:
UWP How to get StorageDevice freespace and capacity?
(3 answers)
Closed 3 years ago.
I am creating a UWP application. I have a use case where I need to print the amount of free local storage available in GB on the windows device on which the app is running. How can this be done?
For this you can use the DriveInfo class. Following this link will provide you with examples System.IO - DriveInfo. Remember to take into consideration how to print the free storage if the device has more than one internal storage device.

How to make an installable .Net console app [duplicate]

This question already has answers here:
C# set environment variable
(2 answers)
Ways to deploying console applications in C#
(5 answers)
Closed 4 years ago.
How can I make my console app installable so that when I open CMD I can run it from anywhere with a keyword. Like when I type in git in cmd for example. Thanks.
For this, you need to set up an environment variable called PATH. In Windows, it is in the registry. But for Mac or Linux you may want to update the .bash_profile file.
You can use the following function
SetEnvironmentVariable(String, String)
Here is the link for the MSDN .net core API
Then again I haven't tried this before. But hope this helps you out.

How to detect a running MSI Installation [duplicate]

This question already has answers here:
How do I test if another installation is already in progress?
(3 answers)
Closed 7 years ago.
I'm looking for a way to detect if a Windows Installer installation is already in progress. What I've found out so far is:
Checking the Registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\InProgress
Using the Windows Installer API function MSIInstallProduct with a dummy file which then would return the specific error code.
Does anybody know a smarter solution?
Same as this:
check for windows installer mutex availability
and this:
http://blogs.msdn.com/b/heaths/archive/2006/01/23/516454.aspx
Question 1:
http://blogs.msdn.com/b/windows_installer_team/archive/2005/11/09/487559.aspx

Get App Version Number [duplicate]

This question already has answers here:
How to get app version in Windows Phone?
(11 answers)
Closed 8 years ago.
How do you get the app version number? It's clear how to get OS version number etc, but nothing seems to be documented on getting the app version from the manifest?
Getting OS Version number works as such:
var VersionNumber = Environment.OSVersion.Version;
btn.Content = VersionNumber;
You can get the Version from the manifest by loading the .xml like this:
string Version = XDocument.Load("WMAppManifest.xml")
.Root.Element("App").Attribute("Version").Value;

Working out version of windows [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to detect Windows 64 bit platform with .net?
How do you know if the operating system is x64 or x86 from a c# .net 2.0 windows applicaiton?
Also the applicaiton is 32bit.
Thanks
Use GetEnvironmentVariable to look for the PROCESSOR_ARCHITEW6432 variable. If it doesn't exist, you must be running 32bit:
bool is64bit = !string.IsNullOrEmpty(
Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"));
EDIT:
Thanks to Hans Passant for pointing out the error in using the PROCESSOR_ARCHITECTURE variable.

Categories