1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
int Class::countOfDocuments(wchar_t buffer[10])
{
wchar_t driveString[MAX_PATH + 1] = { 0 };
wcsncat_s(driveString,260,buffer,260);
wcsncat_s(driveString, 260, L"*doc", 260);
WIN32_FIND_DATA documents;
HANDLE hFind; bool var = true;
hFind = FindFirstFile(driveString, &documents);
if (INVALID_HANDLE_VALUE == hFind)
{
wchar_t* no = L"No documents found";
SendMessage(list1, LB_ADDSTRING, NULL, (LPARAM)no);
for (int i = 0; i <= 10; i++)
{
SendMessage(cprogress, PBM_SETRANGE, 0, i);
SendMessage(cprogress, PBM_SETSTEP, (WPARAM)1, 0);
SendMessage(cprogress, PBM_STEPIT, 0, 1);
}
return count = -1;
}
else
{
wchar_t* Yes = L"Document found";
perform = true;
SendMessage(list1, LB_ADDSTRING, NULL, (LPARAM)Yes);
while (var = FindNextFile(hFind, &documents) == TRUE)
{
count++;
}
for (int i = 0; i <= count; i++)
{
SendMessage(cprogress, PBM_SETRANGE, 0, i);
SendMessage(cprogress, PBM_SETSTEP, (WPARAM)1, 0);
SendMessage(cprogress, PBM_STEPIT, 0, 1);
wchar_t* doc = L"Document found";
SendMessage(list1, LB_ADDSTRING, NULL, (LPARAM)doc);
}
wchar_t* z = L"search complete";
SendMessage(list1, LB_ADDSTRING, NULL, (LPARAM)z);
}
return count;
}
|