C++erreur convertion char* to LPCWSTR

Fermé
MounaRM Messages postés 19 Date d'inscription jeudi 10 juin 2010 Statut Membre Dernière intervention 27 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;

void AfficherListeFichiers (string Dossier)
{
HANDLE hFind;
WIN32_FIND_DATA FindData;
std::string LstrPattern;
// Change de dossier

LPCWSTR lp_wms_filepath;
wchar_t* p_wms_filepath = NULL;
mbstowcs( p_wms_filepath, Dossier.c_str(), Dossier.size() );
lp_wms_filepath = p_wms_filepath;
SetCurrentDirectory (lp_wms_filepath);

// 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);
}




merci d'avance pour votre aide.
A voir également: