コード例 #1
0
ファイル: Form1.cs プロジェクト: yinwun/SATools
        private void LoadRunningVMS()
        {
            COMLIB cb  = new COMLIB();
            string str = cb.RunCmd2(Path.Combine(vbEXEPath, vbExe), "list runningvms");

            if (String.IsNullOrEmpty(str))
            {
                MessageBox.Show("Error");
                return;
            }

            string[] strResults = str.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            for (int i = 3; i < strResults.Length; i++)
            {
                string doubleQuote = "\"";
                string tmp         = strResults[i].Replace(@"\", String.Empty);
                tmp = tmp.Replace(doubleQuote, String.Empty);
                tmp = tmp.Replace("{", String.Empty);
                tmp = tmp.Replace("}", String.Empty);
                string[] strvms = tmp.Split(' ');
                if (strvms.Length == 2)
                {
                    if (dctRunningVms.ContainsKey(strvms[1]))
                    {
                        continue;
                    }
                    dctRunningVms.Add(strvms[1], strvms[0]);
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: yinwun/SATools
        private VMInfo GetVMInfo(ref VMInfo info)
        {
            COMLIB cb  = new COMLIB();
            string str = cb.RunCmd2(Path.Combine(vbEXEPath, vbExe), String.Format("showvminfo {0}", info.Guid));

            if (String.IsNullOrEmpty(str))
            {
                MessageBox.Show("Error");
                return(null);
            }

            string[] strResults = str.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            for (int i = 3; i < strResults.Length; i++)
            {
                if (strResults[i].Contains("Groups"))
                {
                    string[] strvms = strResults[i].Split(':');
                    if (strvms.Length > 0)
                    {
                        string tmpGroups = strvms[1].Replace(" ", String.Empty);
                        tmpGroups  = tmpGroups.Replace("/", String.Empty);
                        info.Group = tmpGroups;
                        if (!lstGroup.Contains(tmpGroups))
                        {
                            lstGroup.Add(tmpGroups);
                        }
                        continue;
                    }
                }
            }

            return(info);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: yinwun/SATools
        private void GetscreenShoto(string vmGUID)
        {
            COMLIB cb  = new COMLIB();
            string str = cb.RunCmd2(Path.Combine(vbEXEPath, vbExe), String.Format("controlvm {0} {1}.png", vmGUID, Path.Combine(runningPath, String.Format("{0}\\{1}", screenShotFolder, vmGUID))));

            if (String.IsNullOrEmpty(str))
            {
                MessageBox.Show("Error");
                return;
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: yinwun/SATools
        private void ShutDownVM(string vmGUID)
        {
            COMLIB cb  = new COMLIB();
            string str = cb.RunCmd2(Path.Combine(vbEXEPath, vbExe), String.Format("controlvm {0} acpipowerbutton", vmGUID));

            if (String.IsNullOrEmpty(str))
            {
                MessageBox.Show("Error");
                return;
            }

            if (str.Contains("100%"))
            {
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: yinwun/SATools
        private void StartVM(string vmGUID)
        {
            COMLIB cb  = new COMLIB();
            string str = cb.RunCmd2(Path.Combine(vbEXEPath, vbExe), String.Format("startvm {0}", vmGUID));

            if (String.IsNullOrEmpty(str))
            {
                MessageBox.Show("Error");
                return;
            }

            if (str.Contains("started"))
            {
                int st = 0;
                int.TryParse(sleepTime, out st);
                System.Threading.Thread.Sleep(st);
            }
        }