Esempio n. 1
0
        private static void SetXenBusDevUsedOnFirstRun(
            RegistryKey openRegKey)
        // Keeps the XenBus device that was used on
        // the Install Agent's first run
        {
            string regValName = "XenBusDevUsedOnFirstRun";

            try
            {
                xenBusDev = (XenBus.Devs)Enum.Parse(
                    typeof(XenBus.Devs),
                    (string)openRegKey.GetValue(regValName),
                    true
                    );
            }
            catch (ArgumentNullException)
            // <value> does not exist; first run of Install Agent
            {
                string tmp = "";

                foreach (XenBus.Devs tmpXenBus in
                         Enum.GetValues(typeof(XenBus.Devs)))
                {
                    if (!XenBus.IsPresent(tmpXenBus, true) ||
                        !XenBus.HasChildren(tmpXenBus))
                    {
                        continue;
                    }

                    tmp       = tmpXenBus.ToString();
                    xenBusDev = tmpXenBus;
                    break;
                }

                if (String.IsNullOrEmpty(tmp))
                {
                    xenBusDev = (XenBus.Devs) 0;
                }

                openRegKey.SetValue(
                    regValName,
                    tmp,
                    RegistryValueKind.String
                    );
            }
            catch (ArgumentException)
            // <value> exists, but is empty =>
            // no XenBus dev used =>
            // no PV drivers installed
            {
                xenBusDev = (XenBus.Devs) 0;
            }
        }
Esempio n. 2
0
        // Keeps the XenBus device that was used on
        // the Install Agent's first run
        private static void SetXenBusDevUsedOnFirstRun(
            RegistryKey openRegKey)
        {
            string regValName = "XenBusDevUsedOnFirstRun";

            try
            {
                xenBusDev = (XenBus.Devs)Enum.Parse(
                    typeof(XenBus.Devs),
                    (string)openRegKey.GetValue(regValName),
                    true
                );
            }
            catch (ArgumentNullException)
            // <value> does not exist; first run of Install Agent
            {
                string tmp = "";

                foreach (XenBus.Devs tmpXenBus in
                         Enum.GetValues(typeof(XenBus.Devs)))
                {
                    if (!XenBus.IsPresent(tmpXenBus, true) ||
                        !XenBus.HasChildren(tmpXenBus))
                    {
                        continue;
                    }

                    tmp = tmpXenBus.ToString();
                    xenBusDev = tmpXenBus;
                    break;
                }

                if (String.IsNullOrEmpty(tmp))
                {
                    xenBusDev = (XenBus.Devs)0;
                }

                openRegKey.SetValue(
                    regValName,
                    tmp,
                    RegistryValueKind.String
                );
            }
            catch (ArgumentException)
            // <value> exists, but is empty =>
            // no XenBus dev used =>
            // no PV drivers installed
            {
                xenBusDev = (XenBus.Devs)0;
            }
        }