我需要帮助从 WIN32_FIND_DATA 我的代码获取完整路径:
WIN32_FIND_DATA FindData;
HANDLE hFind;
hFind = FindFirstFile(L"../art/*.dds", &FindData );
if( hFind == INVALID_HANDLE_VALUE )
{
PrintCharS("Error searching directory");
return;
}
do
{
char ch[260];
char DefChar = ' ';
WideCharToMultiByte(CP_ACP, 0, FindData.cFileName, -1, ch, 260, &DefChar, NULL);
string ss(ch);
if (ch != "invalid.dds")
{
LoadFile( / Need WCHAR* that points to file \ );
}
}
while( FindNextFile(hFind, &FindData) > 0 );
我真的花了一整天的时间试图弄清楚这一点。但我无法获取路径(../art/*.dds)加上文件名,我如何检查子文件夹?还是已经这样做了?
当前代码:
WIN32_FIND_DATA FindData;
HANDLE hFind;
hFind = FindFirstFile(L"../art/*.dds", &FindData );
if( hFind == INVALID_HANDLE_VALUE )
{
PrintCharS("Error searching directory");
return;
}
do
{
char ch[260];
char DefChar = ' ';
WideCharToMultiByte(CP_ACP, 0, FindData.cFileName, -1, ch, 260, &DefChar, NULL);
string ss(ch);
// Just incase they're needed
DWORD retval=0;
BOOL success;
TCHAR buffer[4096]=TEXT("");
TCHAR buf[4096]=TEXT("");
TCHAR** lppPart={NULL};
LPSTR buffeer = "";
LPSTR* lpppPart = NULL;
retval = GetFullPathNameA(ch, 4096, buffeer, lpppPart);
if (retval == 0)
{
std::exit(1);
}
else
{
LoadFile( / Expected WCHAR* \ );
}
}
while( FindNextFile(hFind, &FindData) > 0 );