3 using System.Windows.Forms;
5 using System.Runtime.InteropServices;
12 [DllImport("msi.dll", SetLastError = true)]
13 static extern int MsiEnumProducts(int iProductIndex, StringBuilder lpProductBuf);
15 [DllImport("msi.dll", CharSet = CharSet.Unicode)]
16 static extern Int32 MsiGetProductInfo(string product, string property, [Out] StringBuilder valueBuf, ref Int32 len);
18 public static string Icinga2InstallDir
22 StringBuilder szProduct;
24 for (int index = 0; ; index++) {
25 szProduct = new StringBuilder(39);
26 if (MsiEnumProducts(index, szProduct) != 0)
30 StringBuilder szName = new StringBuilder(cbName);
32 if (MsiGetProductInfo(szProduct.ToString(), "ProductName", szName, ref cbName) != 0)
35 if (szName.ToString() != "Icinga 2")
38 int cbLocation = 1024;
39 StringBuilder szLocation = new StringBuilder(cbLocation);
40 if (MsiGetProductInfo(szProduct.ToString(), "InstallLocation", szLocation, ref cbLocation) == 0)
41 return szLocation.ToString();
48 public static string Icinga2DataDir
52 return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\icinga2";
57 public static void FatalError(Form owner, string message)
59 MessageBox.Show(owner, message, "Icinga 2 Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
64 /// The main entry point for the application.
69 Application.EnableVisualStyles();
70 Application.SetCompatibleTextRenderingDefault(false);
72 string installDir = Program.Icinga2InstallDir;
74 if (installDir == "") {
75 FatalError(null, "Icinga 2 does not seem to be installed properly.");
81 if (File.Exists(Program.Icinga2DataDir + "\\etc\\icinga2\\features-enabled\\api.conf"))
82 form = new ServiceStatus();
84 form = new SetupWizard();
86 Application.Run(form);