Ejemplo n.º 1
0
 public VirtualPC_VM(string FilePath) : base(FilePath)
 {
     if (FilePath == null)
     {
         return;
     }
     XML = new VirtualPC_XML(FilePath);
 }
Ejemplo n.º 2
0
        public static void SearchVM(ref List <VirtualMachine> VMList)
        {
            var RoamingAppdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var UserProfile    = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            var Version7Folder = Path.Combine(UserProfile, "Virtual Machines");
            var VMFolder       = Path.Combine(RoamingAppdata, @"Microsoft\Virtual PC\Virtual Machines");

            string[] Files;

            //Virtual 2004 2007
            if (Directory.Exists(VMFolder))
            {
                Files = Directory.GetFiles(VMFolder);
                foreach (string lnkFile in Files)
                {
                    if (Path.GetExtension(lnkFile) == ".lnk")
                    {
                        var Shell = new IWshRuntimeLibrary.WshShell();
                        IWshRuntimeLibrary.WshShortcut Shortcut = Shell.CreateShortcut(lnkFile);
                        var Target = Shortcut.TargetPath;

                        if (File.Exists(Target) && (Path.GetExtension(Target) == ".vmc"))
                        {
                            var VM = new VirtualPC_VM(Target);
                            VMList.Add(VM);
                        }
                    }
                }
            }

            //Windows Virtual PC (Version7)
            if (Directory.Exists(Version7Folder))
            {
                Files = Directory.GetFiles(Version7Folder);
                foreach (string vmcx in Files)
                {
                    if (Path.GetExtension(vmcx) == ".vmcx")
                    {
                        var XML    = new VirtualPC_XML(vmcx);
                        var Target = XML.ReadValue(@"vm_description/vmc_path");

                        if (File.Exists(Target) && (Path.GetExtension(Target) == ".vmc"))
                        {
                            var VM = new VirtualPC_VM(Target);
                            VMList.Add(VM);
                        }
                    }
                }
            }
        }