+ StringBuilder szProduct;
+
+ for (int index = 0; ; index++) {
+ szProduct = new StringBuilder(39);
+ if (NativeMethods.MsiEnumProducts(index, szProduct) != 0)
+ break;
+
+ int cbName = 128;
+ StringBuilder szName = new StringBuilder(cbName);
+
+ if (NativeMethods.MsiGetProductInfo(szProduct.ToString(), "ProductName", szName, ref cbName) != 0)
+ continue;
+
+ if (szName.ToString() != "Icinga 2")
+ continue;
+
+ int cbLocation = 1024;
+ StringBuilder szLocation = new StringBuilder(cbLocation);
+ if (NativeMethods.MsiGetProductInfo(szProduct.ToString(), "InstallLocation", szLocation, ref cbLocation) == 0)
+ return szLocation.ToString();
+ }
+
+ return "";
+ }
+ }
+
+ public static string Icinga2DataDir
+ {
+ get
+ {
+ return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\icinga2";
+ }
+ }