This is how I check for the Kinect Runtime, in my App.xaml.cs:
using Microsoft.Kinect;
using System;
using System.Linq;
using System.Windows;
namespace WpfApplication {
public partial class App : Application {
protected override void OnStartup(StartupEventArgs e) {
if (IsKinectRuntimeInstalled) {
base.OnStartup(e);
}
else {
MessageBoxResult result = MessageBox.Show("Microsoft Kinect Runtime 1.8 is required.\nClick \"OK\" to download Microsoft Kinect Runtime 1.8 from Microsoft's website.",
"Kinect Runtime required",
MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK) {
System.Diagnostics.Process.Start("http://www.microsoft.com/en-us/download/details.aspx?id=40277");
}
}
}
public bool IsKinectRuntimeInstalled {
get {
bool isInstalled;
try {
TestForKinectTypeLoadException();
isInstalled = true;
}
catch (TypeInitializationException) {
isInstalled = false;
}
return isInstalled;
}
}
private void TestForKinectTypeLoadException() {
KinectSensor kinectCheck = KinectSensor.KinectSensors.FirstOrDefault();
}
}
}
Inspired by this post.
I'm using the Kinect SDK 1.8 and .NET 4.5.
As far as I know, up to version 1.8, there's no registry key to check.
It's also possible to bundle the Kinect Runtime Redistributable into your installer and execute it during install, e.g. via a Custom Action. I have two problems with relying on this method:
- The 1.8 redistributable is ~120 MB, "too beaucoup."
- The runtime may somehow get deleted or broken some time after the install. If I don't have this check at startup, my application will crash inexplicably (for the lay-user).