代码拉取完成,页面将自动刷新
#include "StdAfx.h"
#include "CPath.h"
////////////////////////////////////////////////////////
CEnumPath::~CEnumPath()
{
for (int i = 0; i < m_nCount; i++)
{
if (m_Path[i] != NULL)
{
delete [] m_Path[i];
m_Path[i] = NULL;
}
}
m_nCount = 0;
}
CEnumPath::CEnumPath(const wchar_t* pPath,BOOL bDir,BOOL bFullPath):m_nCount(0)
{
ZeroMemory(m_Path,sizeof(wchar_t*)*MAX_PATH);
WIN32_FIND_DATAW FileData={0};
wchar_t TempPath[MAX_PATH] = {0};
wcscpy(TempPath,pPath);
if (TempPath[wcslen(pPath)] != L'\\')
{
wcscat(TempPath,L"\\");
}
wcscat(TempPath,L"*.*");
HANDLE hSearch = FindFirstFileW(TempPath, &FileData);
if (hSearch == INVALID_HANDLE_VALUE)
{
return;
}
BOOL fFinished = FALSE;
m_nCount = 0;
while (!fFinished)
{
if ((wcscmp(FileData.cFileName,L".") != 0) && (wcscmp(FileData.cFileName,L"..") != 0))
{
if ( (FILE_ATTRIBUTE_DIRECTORY & FileData.dwFileAttributes) != 0 )
{
if (bDir == TRUE)
{
m_Path[m_nCount] = new wchar_t[MAX_PATH_XC];
ZeroMaxPathXC(m_Path[m_nCount]);
if (bFullPath == TRUE)
{
wcscat(m_Path[m_nCount],pPath);
wcscat(m_Path[m_nCount],L"\\");
}
wcscat(m_Path[m_nCount],FileData.cFileName);
m_nCount++;
}
}else
{
if (bDir == FALSE)
{
m_Path[m_nCount] = new wchar_t[MAX_PATH_XC];
ZeroMaxPathXC(m_Path[m_nCount]);
if (bFullPath == TRUE)
{
wcscat(m_Path[m_nCount],pPath);
wcscat(m_Path[m_nCount],L"\\");
}
wcscat(m_Path[m_nCount],FileData.cFileName);
m_nCount++;
}
}
}
ZeroMemory(&FileData,sizeof(FileData));
if (!FindNextFileW(hSearch, &FileData))
{
if (GetLastError() == ERROR_NO_MORE_FILES)
{
fFinished = TRUE;
}
else
{
FindClose(hSearch);
return ;
}
}
}
FindClose(hSearch);
}
wchar_t* CEnumPath::operator[](int n)
{
return m_Path[n];
}
int CEnumPath::GetItemCount()
{
return m_nCount;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。