예제 #1
0
파일: Form1.cs 프로젝트: denglihui1721/test
        public int StartupEm(string aEmName)
        {
            em sEm = new em();

            string[] arg = new string[1];
            arg[0]  = aEmName;
            sEm.pid = StartProcess(@textBox1.Text + exec.EM, arg);
            Thread.Sleep(5000);
            int hwnd = sDm.FindWindowByProcessId(sEm.pid, "", "");

            //string title = sDm.GetWindowTitle(hwnd);
            sEm.name = aEmName;
            sEm.hwnd = hwnd;
            //sEm.title = title;
            LoadEMConfig(ref sEm);
            emList.Add(sEm);
            return(sEm.pid);
        }
예제 #2
0
파일: Form1.cs 프로젝트: denglihui1721/test
        public int LoadEMConfig(ref em sEm)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(@textBox1.Text + "MemuHyperv VMs\\" + sEm.name + "\\" + sEm.name + ".memu");
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable);

            nsMgr.AddNamespace("ns", "http://www.innotek.de/MemuHyperv-settings");
            //XmlNode node = xmlDoc.SelectSingleNode("/ns:MemuHyperv/ns:Machine/ns:Hardware/ns:Network/ns:NAT/ns:Forwarding", nsMgr);
            XmlNodeList node = xmlDoc.SelectNodes("/ns:MemuHyperv/ns:Machine/ns:Hardware/ns:Network/ns:Adapter/ns:NAT/ns:Forwarding", nsMgr);

            sEm.ip   = node[0].Attributes["hostip"].Value;
            sEm.port = Convert.ToInt32(node[0].Attributes["hostport"].Value);
            XmlNodeList node2 = xmlDoc.SelectNodes("/ns:MemuHyperv/ns:Machine/ns:Hardware/ns:GuestProperties/ns:GuestProperty", nsMgr);

            foreach (XmlNode n in node2)
            {
                if (n.Attributes["name"].Value == "name_tag")
                {
                    sEm.title = n.Attributes["value"].Value;
                }
            }
            return(1);
        }