面对现实,超越自己
逆水行舟,不进则退
posts - 269,comments - 32,trackbacks - 0
 1     CString sTempIPs;
 2     sTempIPs.Format("%s%s", CCommonFun::GetTmpPath(), "TempIPs.txt");
 3 
 4     ::DeleteFile(sTempIPs);
 5     CString sPara;
 6     sPara.Format("/c ipconfig.exe | findstr \"IP Address\" > \"%s\"", sTempIPs);
 7     CCommonFun::WinExecAndWait32("cmd.exe", sPara, CCommonFun::GetExecutablePath(), INFINITE);
 8 
 9     if (CFileFind().FindFile(sTempIPs))
10     {
11         CString sLine, sIP;
12         CString sFlag = "";
13         CStdioFile stdFile;
14         if (stdFile.Open(sTempIPs,  CFile::modeRead))
15         {
16             while (stdFile.ReadString(sLine))
17             {
18                 int nPos = sLine.Find(sFlag);
19                 if (nPos != -1)
20                 {
21                     sIP = sLine.Mid(nPos+sFlag.GetLength(), sLine.GetLength()-(nPos+sFlag.GetLength()));
22                     sIP.TrimLeft();
23                     sIP.TrimRight();
24                     arsLocalIPs.Add(sIP);
25                 }
26             }
27         }
28     }
posted on 2012-09-29 14:33 王海光 阅读(547) 评论(0)  编辑 收藏 引用 所属分类: MFC

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理