Example #1
0
        private void RefreshFormData()
        {
            ServiceController service = ServicesHelper.GetOpenDentServiceByName(textName.Text);

            if (service != null)           //installed
            {
                RegistryKey hklm = Registry.LocalMachine;
                hklm = hklm.OpenSubKey(@"System\CurrentControlSet\Services\" + service.ServiceName);
                textPathToExe.Text     = hklm.GetValue("ImagePath").ToString().Replace("\"", "");
                textStatus.Text        = "Installed";
                butInstall.Enabled     = false;
                butUninstall.Enabled   = true;
                butBrowse.Enabled      = false;
                textPathToExe.ReadOnly = true;
                textName.ReadOnly      = true;
                if (service.Status == ServiceControllerStatus.Running)
                {
                    textStatus.Text += ", Running";
                    butStart.Enabled = false;
                    butStop.Enabled  = true;
                }
                else
                {
                    textStatus.Text += ", Stopped";
                    butStart.Enabled = true;
                    butStop.Enabled  = false;
                }
            }
            else
            {
                textStatus.Text        = "Not installed";
                textName.ReadOnly      = false;
                textPathToExe.ReadOnly = false;
                butInstall.Enabled     = true;
                butUninstall.Enabled   = false;
                butStart.Enabled       = false;
                butStop.Enabled        = false;
            }
            if (_isInstallOnly)
            {
                butUninstall.Enabled = false;
            }
        }