I need to get the extension from filename and compare it to my array of extensions. But looks like TCHAR
do not have strpos()
-like function, so I am walking an array of TCHAR
(not the best solution?) to search for the '.'
sign and extract a file extension. But it doesn't work.
for (int i = 0; i < extCount; i++)
{
//wsprintf(fileName, L"%d", extCount);
//_tcscpy_s(fileName, extensions[i]);
_tcscpy_s(fileName, fileData.cFileName);
for (int k = wcslen(fileName); k >= 0; k--)
{
if (fileName[k] == (LPCWSTR)TCHAR('.'))
{
wsprintf(temp, L"%c", fileName[k]);
MessageBox(NULL, fileName[k], L"Файл", MB_OK);
}
}
So the problem is, how to get and compare the file extension in simpliest and most effective way? And other question is - should I really use TCHAR
? Because there is so much trouble with this type. When do they used on practice?