Ejemplo n.º 1
0
        public static SetupConfig BuildSetupConfig(string path)
        {
            SetupConfig config  = new SetupConfig();
            AcadProduct product = AcadProductManager.GetProduct();

            _xmlConfig.Element("Folders").Elements().ToList().ForEach(x =>
            {
                config.SourceAndTargetFolders.Add(x.AttValue("Source"), string.Format(x.AttValue("Target"), path, product.Path));
            });
            _xmlConfig.Element("Desktop").Elements().ToList().ForEach(x =>
            {
                Shortcut sc = new Shortcut(x.AttValue("Name"), GetDesktop(), string.Format(x.AttValue("Target"), path))
                {
                    Description = x.AttValue("Description"), Args = x.AttValue("Args"), Icon = x.AttValue("Icon")
                };
                config.DesktopShortcuts.Add(sc);
            });
            _xmlConfig.Element("StartMenu").Elements().ToList().ForEach(x =>
            {
                string programStartMenu = GetStartMenu() + "\\" + x.AttValue("Folder");
                if (!System.IO.Directory.Exists(programStartMenu))
                {
                    System.IO.Directory.CreateDirectory(programStartMenu);
                }
                Shortcut sc = new Shortcut(x.AttValue("Name"), programStartMenu, string.Format(x.AttValue("Target"), path))
                {
                    Description = x.AttValue("Description"), Args = x.AttValue("Args"), Icon = x.AttValue("Icon")
                };
                config.StartMenuShortcuts.Add(sc);
            });
            return(config);
        }
Ejemplo n.º 2
0
        static AcadProductManager()
        {
            string[] cadLocations = { "SOFTWARE\\Autodesk\\AutoCAD", "SOFTWARE\\Wow6432Node\\Autodesk\\AutoCAD" };

            foreach (var location in cadLocations)
            {
                RegistryKey x64 = Registry.LocalMachine.OpenSubKey(location);
                if (x64 == null) // running on x86 machines cannot get the second location
                {
                    continue;
                }
                string[] versions = x64.GetSubKeyNames();
                foreach (string version in versions)
                {
                    RegistryKey versionKey = x64.OpenSubKey(version);
                    string[]    products   = versionKey.GetSubKeyNames();
                    foreach (string product in products)
                    {
                        RegistryKey productKey = versionKey.OpenSubKey(product);
                        try
                        {
                            AcadProduct productDef = new AcadProduct {
                                Name = productKey.GetValue("ProductName").ToString(), Path = productKey.GetValue("AcadLocation").ToString(), Version = version.Substring(1), RegKey = productKey.Name
                            };
                            cads.Add(productDef);
                        }
                        catch
                        {
                        }
                        productKey.Close();
                    }
                    versionKey.Close();
                }
                x64.Close();
            }
        }