I'm currently working on an application for Windows written in WPF (C#) and I want to have some features enabled only when the application is running on an Apple computer which is running Windows via Bootcamp. I didn't find any questions about it anywhere nor solutions for it online. Is it possible to detect Bootcamp? If so, how?
I have never thought of checking BIOS Vendor information. Thanks to Kell for the idea. Here is a solution for others:
First of all, you need to add System.Management
as a reference. You'll also need to add these namespaces:
using System.Management;
using Windows.System;
After this, you'll need the following code to understand if the machine is made by Apple or not:
public bool IsMadeByApple()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
ManagementObjectCollection collection = searcher.Get();
string manufacturer = "";
foreach (ManagementObject obj in collection)
{
manufacturer = (string)obj["Manufacturer"]; // Will be "Apple Inc." if it's an Apple computer
}
return (manufacturer == "Apple Inc.");
}
You can use it like this:
MessageBox.Show(IsMadeByApple().ToString());
This will pop up a message box. It will say "True" if it's an Apple computer, if not then it will say "False".
This solution is only tested on an Early 2015 MacBook Pro running Bootcamp. This solution may not work on different models, but it will likely work.