Exemplo n.º 1
0
        private void WriteEntryToReg(vmEntry entry)
        {
            ownWrite = true;
            try
            {
                Debug.WriteLine("Opening Registry");

                RegistryKey key = Registry.LocalMachine.CreateSubKey(regDir);
                int vmNumber;
                string tempVMFile, tempVMTimestamp,tempVMUsername,tempVMPassword;

                if (key != null)
                {

                            tempVMUsername = vmUsername + entry.indexNum;
                            tempVMPassword = vmPassword + entry.indexNum;
                            tempVMTimestamp = vmTimestamp + entry.indexNum;

                        key.SetValue(tempVMTimestamp, entry.timestamp.ToString());
                        key.SetValue(tempVMUsername, entry.username);
                        key.SetValue(tempVMPassword, entry.password);

                    key.Close();
                }
                ownWrite = false;
            }
            catch (Exception e)
            {
                Debug.WriteLine("Exception while adding entry to Reg " + e.Message);
            }
        }
Exemplo n.º 2
0
        private void DeleteEntryFromReg(vmEntry entry)
        {
            try
            {
                Debug.WriteLine("Opening Registry");
                RegistryKey key = Registry.LocalMachine.CreateSubKey(regDir);

                string tempVMTimestamp,tempUsername,tempPassword;

                if (key != null)
                {
                    if (key.GetValue(numVM) != null)
                    {

                        tempVMTimestamp = vmTimestamp + entry.indexNum;
                        tempUsername=vmUsername+entry.indexNum;
                        tempPassword=vmPassword+entry.indexNum;

                        key.DeleteValue(tempVMTimestamp);
                        key.DeleteValue(tempUsername);
                        key.DeleteValue(tempPassword);

                    }
                    key.Close();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Exception while deleting entry from Reg " + e.Message);
            }
        }
Exemplo n.º 3
0
        private void GetVMInfo()
        {
            try
            {
                Debug.WriteLine("Opening Registry");
                RegistryKey key = Registry.LocalMachine.OpenSubKey(regDir);

                string tempVMName, tempVMFile, tempVMSnapshot, tempVMUsername, tempVMPassword, tempVMTimestamp;

                if (key != null)
                {
                    Debug.WriteLine("Successfully opened Registry");
                    if (key.GetValue(numVM) != null)
                    {
                        numVMs = Convert.ToInt32(key.GetValue(numVM).ToString());

                        for (int i = 1; i <= numVMs; i++)
                        {
                            tempVMName = vmName + i;
                            tempVMFile = vmFile + i;
                            tempVMSnapshot = vmSnapshot + i;
                            tempVMUsername = vmUsername + i;
                            tempVMPassword = vmPassword + i;
                            tempVMTimestamp = vmTimestamp + i;

                            Debug.WriteLine("Temp VM String " + tempVMName + " " + tempVMFile + " " + tempVMSnapshot);

                            vmEntry entry = new vmEntry();
                            entry.indexNum = i;
                            if (key.GetValue(tempVMName) != null)
                            {
                                entry.vmName = key.GetValue(tempVMName).ToString();
                            }
                            if (key.GetValue(tempVMFile) != null)
                            {
                                entry.vmFile = key.GetValue(tempVMFile).ToString();
                            }
                            if (key.GetValue(tempVMSnapshot) != null)
                            {
                                entry.snapshotName = key.GetValue(tempVMSnapshot).ToString();
                            }
                            if (key.GetValue(tempVMUsername) != null)
                            {
                                entry.username = key.GetValue(tempVMUsername).ToString();
                                entry.password = key.GetValue(tempVMPassword).ToString();
                                entry.timestamp = Convert.ToDateTime(key.GetValue(tempVMTimestamp).ToString());
                                entry.busy = true;
                                queue.Enqueue(entry);

                            }
                            else
                            {
                                 entry.busy = false;
                            }

                            vmList.Add(entry);
                        }
                    }
                    key.Close();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine( "Exception while reading from reg " + e.Message);
            }
        }