I done it myself like this..
Make use of it..
#include "stdafx.h"
#include <windows.h>
#include <Shlobj.h>
#include <iostream.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <conio.h>
using namespace std;
int FindFolder(string, string, int);
#define FOLD 16
typedef struct
{
string FolderName;
int Foldersize;
int FolderFiles;
}DeskFold;
int files;
int main(int argc, char *argv[])
{
WIN32_FIND_DATA FindFileData;
char cArr[1000];
int icount = 0;
int i;
string sTmp;
HWND hwnd;
HANDLE hFind;
vector<DeskFold> MyVect;
DeskFold SObj;
SHGetSpecialFolderPath(hwnd,cArr,CSIDL_DESKTOP,0);
sTmp.assign(cArr);
sTmp.append("\\");
string sPath;
sPath.assign(sTmp);
sPath.append("*");
hFind = FindFirstFile(sPath.data(), &FindFileData);
do
{
if(FindFileData.dwFileAttributes == FOLD)
{
icount++;
if( icount > 2)
{
SObj.FolderName.assign(FindFileData.cFileName);
files = 0;
SObj.Foldersize = FindFolder(sTmp, FindFileData.cFileName, 0);
SObj.FolderFiles = files;
MyVect.push_back(SObj);
}
}
}while (FindNextFile(hFind, &FindFileData));
FindClose(hFind);
for(i = 0; i<MyVect.size(); i++)
{
cout<<"Folder name : "<<MyVect.at(i).FolderName.data()<<endl;
cout<<"Folder size : "<<MyVect.at(i).Foldersize<<endl;
cout<<"Folder files : "<<MyVect.at(i).FolderFiles<<endl<<endl;
}
cout<<"\nTotal number of folders in desktop : "<<icount-2<<endl;
return 0;
}
int FindFolder(string sPath, string FileName, int foldersize)
{
int icount = 0;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
string sPath1;
sPath.append(FileName.data());
sPath.append("\\");
sPath1.append(sPath);
sPath1.append("*");
hFind = FindFirstFile(sPath1.data(), &FindFileData);
do
{
foldersize += FindFileData.nFileSizeLow;
if(FindFileData.dwFileAttributes == 16)
{
icount++;
if( icount > 2)
FindFolder(sPath,FindFileData.cFileName,FindFileData.nFileSizeLow);
}
else
files++;
}while (FindNextFile(hFind, &FindFileData));
FindClose(hFind);
return foldersize;
}
Have a nice day