MounaRM
Messages postés19Date d'inscriptionjeudi 10 juin 2010StatutMembreDernière intervention27 avril 2011
-
Modifié par MounaRM le 12/06/2010 à 17:59
Bonjour,
j'essaye de développer un code qui fait une recherche des fichiers sur le disque dur.
la compilation du code produit l erreur suivante:
error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
j ai pas réussis à résoudre ce problème. quelqu'un peut m'aider svp.
voici le code:
#ifdef _UNICODE
#define _T(x) L ## x
#else /* _UNICODE */
#endif /* _UNICODE */
#include <string>
#include <windows.h>
#include <iostream>
#include <fstream>
using namespace std;
// Début de la recherche
LstrPattern="*.*";
hFind=::FindFirstFile(_T(strPattern.c_str()), &FindData);
if (hFind!=INVALID_HANDLE_VALUE)
{
// Si le fichier trouvé n'est pas un dossier mais bien un fichier, on affiche son nom
if (!(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
cout<<"Si le fichier trouvé n'est pas un dossier mais bien un fichier, on affiche son nom"<< endl;
//MessageBox (NULL, FindData.cFileName, "Fichier", MB_ICONINFORMATION);
}
// Fichiers suivants
while (FindNextFile (hFind, &FindData))
{
if (!(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
cout<<"Fichiers suivants"<< endl;
//MessageBox (NULL, FindData.cFileName, "Fichier", MB_ICONINFORMATION);
}
}
}
// Fin de la recherche
FindClose (hFind);
}