Working out version of windows [duplicate] - c#

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.

Related

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.

Getting Windows Build Number programmatically [duplicate]

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

I need the application to detect what operating system is being run on? [duplicate]

This question already has answers here:
Determine OS using Environment.OSVersion [duplicate]
(4 answers)
Closed 6 years ago.
I was going over forums yesterday as my issue is that i need my application to detect what operating system it is using and depending on the operating system, the app does a different function.
The best information i found was the Path.PathSeperator. Can anyone confirm if it is correct and tell me how to use it to detect which operating system is being used?
Thank You Very Much! :)
Environment.OSVersion
Property will help ypu to get the Operating System.
Yes you can change some code lines, but to change all codes is not a good idea.
if(Environment.OSVersion.VersionString.Contains("Windows"))
{
//
}
else
{
}

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

How to place a shortcut in Windows 7 Quick Launch Bar using C# code [duplicate]

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
Create Windows 7 Quick Launch
Is there any method to place a shortcut (lnk file) in the quick launch bar of windows 7 using C# code? The method I used for Win XP doesn't work for Win7:
string strAllUsersAppData = Environment.GetEnvironmentVariable("APPDATA");
string strQuickLaunch = strAllUsersAppData;
strQuickLaunch += #"\Microsoft\Internet Explorer\Quick Launch";
//then i used a method to copy the lnk file in the strQuickLaunch path
I don't know how to create the path for it in Win7. Any ideas?
Thanks
See this CodeProject page; I realize its not C#; however, read the Background paragraph to understand a bit more.

Categories