当前位置: 代码迷 >> WinCE >> 请问一个文件查找的有关问题
  详细解决方案

请问一个文件查找的有关问题

热度:40   发布时间:2016-04-28 13:21:07.0
请教一个文件查找的问题
我想在一目录下查找*.bmp文件,写了如下代码,编译有错误,请高手指点~~
主要代码如下
[code=C/C++][/code]
HANDLE hFile = NULL;
WIN32_FIND_DATAA lpFindFileData;
// BOOL bContinue = FALSE;
int i = 0;
for(i=0;i<50;i++)
  wcscpy(cFileList[i],_T(""));
i = 0;
hFile = FindFirstFile(L"*.bmp",&lpFindFileData);

while (1)
{
strcpy(cFileList[i],&lpFindFileData.cFileName);
if (FindNextFile(m_handle,&lpFindFileData)==0)
{
FindClose(hFile);
break;
}
i++;
nFileTotalCount++;
}

编译错误是:
Deleting intermediate files and output files for project 'Test - Win32 (WCE ARMV4I) Debug'.
--------------------Configuration: Test - Win32 (WCE ARMV4I) Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
CeFileFind.cpp
Test.cpp
TestDlg.cpp
C:\Documents and Settings\hw001\桌面\Test\TestDlg.cpp(131) : error C2664: 'FindFirstFileW' : cannot convert parameter 2 from 'struct _WIN32_FIND_DATAA *' to 'struct _WIN32_FIND_DATAW *'
  Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\hw001\桌面\Test\TestDlg.cpp(135) : error C2664: 'strcpy' : cannot convert parameter 1 from 'unsigned short [8]' to 'char *'
  Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\hw001\桌面\Test\TestDlg.cpp(136) : error C2065: 'm_handle' : undeclared identifier
VOIMAGE.CPP
VOString.cpp
Generating Code...
Error executing clarm.exe.
Creating browse info file...

Test.exe - 3 error(s), 0 warning(s)


------解决方案--------------------
使用WIN32_FIND_DATA,而不是WIN32_FIND_DATAA
------解决方案--------------------
EVC下要使用Unicode
字符串操作要使用wcs前缀的函数,不是str前缀的
  相关解决方案