Bonjour,

je code actuellement sous Visual C++ Express 2010.
Je cherche à compter le nombre de fichiers qu'il y a dans un dossier sous c:\Windows\System32\winevt.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
  std::string folderPath = "C:\\Windows\\System32\\winevt\\Logs"; 
 
  WIN32_FIND_DATAA findData;
  HANDLE hFind = INVALID_HANDLE_VALUE;
 
			std::string searchPath = folderPath + "\\*";
			hFind = FindFirstFileA(folderPath.c_str(), &findData);
 
			if (hFind == INVALID_HANDLE_VALUE) 
			{
				 std::cout << "Erreur lors de l'ouverture du dossier." << std::endl;
        	 }
 
			int Compteur = 0;
 
			do 
			{
				if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) 
				{
					Compteur++;
				}
			} 
			while (FindNextFileA(hFind, &findData) != 0);
 
			FindClose(hFind);
 
			std::cout << "Nombre de fichiers dans le dossier : " << Compteur << std::endl;
Le problème c'est que hFind ne vaut rien, ne retourne rien (0xFFFFFF). Si je mets folderPath = "C:\Windows\Dossierxxx", ca fonctionne très bien.
Est-ce qu'il y a des soucis avec les droits ou quelque chose du genre ??

Merci d'avance pour votre aide.