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
王海光 阅读(554)
评论(0) 编辑 收藏 引用 所属分类:
MFC