windows,分割路径.得出目录

#include <windows.h>
#include <vector>
#include <stdio.h>
#include <string>
using namespace std;
BOOL GetEachLevelDir(PWSTR GetPathName, vector<wstring> &wSavePath,DWORD PathLen) //传入一个路径,获取每一级的目录.并且用数组进行存储.
{
TCHAR *pCurPoint = GetPathName;//使用指针遍历 TCHAR *Begin = GetPathName;
DWORD dwEnd = 0;
DWORD dwCount = 0;
wstring wstrTemp = TEXT("");
while (pCurPoint)
{ //否则进行循环
//wcscmp((TCHAR *)*pCurPoint,TEXT("\\")) == 0
if (*pCurPoint == TEXT('\\'))//以反斜杠为分割.
{ wSavePath.push_back(wstrTemp);
wstrTemp.clear();
pCurPoint++; //控制指针去相加.
dwEnd = 0; } if (*pCurPoint == 0x0)//结尾是0则跳出循环.记录下路径.
{
return TRUE;
break;
}
wstring::iterator it = wstrTemp.begin() + dwEnd;
wstrTemp.insert(it, *pCurPoint); //插入字符
dwEnd++;
pCurPoint++;
dwCount++; //获取判断长度进行退出.
}
return FALSE;
}
上一篇:Java中的集合框架(上)


下一篇:Linux Command Line 解析