Click here to Skip to main content
15,890,512 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Sorting Filenames in CFileDialog Pin
softwaremonkey27-Oct-09 3:40
softwaremonkey27-Oct-09 3:40 
QuestionEncrypt / decrypt a text file using vc++ Pin
kamalilam26-Oct-09 21:13
kamalilam26-Oct-09 21:13 
AnswerRe: Encrypt / decrypt a text file using vc++ Pin
CPallini26-Oct-09 21:39
mveCPallini26-Oct-09 21:39 
AnswerRe: Encrypt / decrypt a text file using vc++ Pin
Hristo-Bojilov26-Oct-09 21:40
Hristo-Bojilov26-Oct-09 21:40 
AnswerRe: Encrypt / decrypt a text file using vc++ Pin
Rajesh R Subramanian26-Oct-09 22:29
professionalRajesh R Subramanian26-Oct-09 22:29 
QuestionHow to find unsued disk space in a Disk programatically. Pin
Shiv Murti Pal26-Oct-09 20:16
Shiv Murti Pal26-Oct-09 20:16 
AnswerRe: How to find unsued disk space in a Disk programatically. Pin
Adam Roderick J26-Oct-09 20:31
Adam Roderick J26-Oct-09 20:31 
AnswerRe: How to find unsued disk space in a Disk programatically. [modified] Pin
Kushagra Tiwari26-Oct-09 20:57
Kushagra Tiwari26-Oct-09 20:57 
Use these functions and get the free space Smile

double funcToGetDriveFreeSpace(LPSTR drive)// give drive name here
{
BOOL success;
CString driveName = drive;
driveName.Append(_T(":\\"));
//LPCTSTR DiskDirectory = _T("C:\\"); // directory name
__int64 AvailableBytes; // number of bytes on disk available to the caller
__int64 TotalBytes; // number of bytes on disk
__int64 FreeBytes; // free bytes on disk
DWORD SectorsPerCluster=0; // pointer to sectors per cluster
DWORD BytesPerSector=0; // pointer to bytes per sector
DWORD FreeClusters=0; // pointer to number of free clusters
DWORD TotalClusters=0; // pointer to total number of clusters

//char FmtNumber[20];
double Size;
char Units[3];

success = GetDiskFreeSpaceEx((CHAR*)driveName.GetString(), (PULARGE_INTEGER) &AvailableBytes,
(PULARGE_INTEGER) &TotalBytes, (PULARGE_INTEGER) &FreeBytes);
if (!success)
{
success = GetDiskFreeSpace((CHAR*)driveName.GetString(), &SectorsPerCluster,
&BytesPerSector, &FreeClusters, &TotalClusters);
FreeBytes = FreeClusters * SectorsPerCluster * BytesPerSector;
TotalBytes = TotalClusters * SectorsPerCluster * BytesPerSector;
if (!success)
{
return -1;
}
}
if (success)
{
fmtsize(FreeBytes,(double&) Size, Units);
return Size;
}
}

void ::fmtsize( __int64 Number, double &Size, char Units[3])
{
const int KB = 1024;
const int MB = 1024*1024;
const int GB = KB*MB;
double DIV;
if (Number>GB)
{
DIV = double(GB);
strcpy(Units,"GB");
}else if (Number > MB)
{
DIV = double(MB);
strcpy(Units,"MB");

}else
{
DIV = double(KB);
strcpy(Units,"KB");
}
Size = Number / DIV;
}


If you like the answer mark this answer as GOOD and close the Thread.

Regards,
Kushagra

I hate coding but I luv to develop Smile | :)

modified on Tuesday, October 27, 2009 3:12 AM

GeneralRe: How to find unsued disk space in a Disk programatically. Pin
Shiv Murti Pal26-Oct-09 21:17
Shiv Murti Pal26-Oct-09 21:17 
AnswerRe: How to find unsued disk space in a Disk programatically. Pin
Kushagra Tiwari26-Oct-09 21:25
Kushagra Tiwari26-Oct-09 21:25 
GeneralRe: How to find unsued disk space in a Disk programatically. Pin
Shiv Murti Pal26-Oct-09 21:46
Shiv Murti Pal26-Oct-09 21:46 
AnswerRe: How to find unsued disk space in a Disk programatically. Pin
Kushagra Tiwari26-Oct-09 22:20
Kushagra Tiwari26-Oct-09 22:20 
QuestionRe: How to find unsued disk space in a Disk programatically. Pin
Adam Roderick J26-Oct-09 23:25
Adam Roderick J26-Oct-09 23:25 
AnswerRe: How to find unsued disk space in a Disk programatically. Pin
Shiv Murti Pal31-Oct-09 2:11
Shiv Murti Pal31-Oct-09 2:11 
QuestionNTSC HD video via HDMI output the hard way. Pin
ChicagoBobT26-Oct-09 13:28
ChicagoBobT26-Oct-09 13:28 
QuestionIntegrate CView desrived class into a dialog box Pin
transoft26-Oct-09 12:13
transoft26-Oct-09 12:13 
AnswerRe: Integrate CView desrived class into a dialog box Pin
Randor 26-Oct-09 16:27
professional Randor 26-Oct-09 16:27 
AnswerRe: Integrate CView desrived class into a dialog box Pin
Iain Clarke, Warrior Programmer27-Oct-09 3:17
Iain Clarke, Warrior Programmer27-Oct-09 3:17 
GeneralRe: Integrate CView desrived class into a dialog box Pin
transoft27-Oct-09 6:22
transoft27-Oct-09 6:22 
QuestionRe: Integrate CView desrived class into a dialog box Pin
David Crow27-Oct-09 6:35
David Crow27-Oct-09 6:35 
AnswerRe: Integrate CView desrived class into a dialog box Pin
transoft27-Oct-09 8:43
transoft27-Oct-09 8:43 
QuestionRe: Integrate CView desrived class into a dialog box Pin
David Crow27-Oct-09 8:49
David Crow27-Oct-09 8:49 
QuestionHow to use IcmpCreateFile(); Pin
Manmohan2926-Oct-09 10:08
Manmohan2926-Oct-09 10:08 
QuestionRe: How to use IcmpCreateFile(); Pin
David Crow26-Oct-09 10:31
David Crow26-Oct-09 10:31 
AnswerRe: How to use IcmpCreateFile(); Pin
Manmohan2926-Oct-09 17:29
Manmohan2926-Oct-09 17:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.