jurij
asked on
drive info
How to determine drive size / free space / label / etc. in visual studio c++ (6)?
A short example if you will, please!
A short example if you will, please!
You would use "GetDiskFreeSpaceEx()" (http://msdn.microsoft.com/library/en-us/fileio/base/getdiskfreespaceex.asp)and "GetVolumeInformation()" (http://msdn.microsoft.com/library/en-us/fileio/base/getvolumeinformation.asp). The links contain sample code. A more complex example would be http://www.microsoft.com/msj/defaulttop.asp?page=/msj/archive/s563a.htm
ASKER
Tought so..
Why does my app crash,when i try to use
ULARGE_INTEGER free;
ULARGE_INTEGER total;
ULARGE_INTEGER totalfree;
GetDiskFreeSpaceEx("C:\\", free,total ,totalfree );
I get the same resoults with GetVolumeInformation(..).
Any clues?
TNX!
Why does my app crash,when i try to use
ULARGE_INTEGER free;
ULARGE_INTEGER total;
ULARGE_INTEGER totalfree;
GetDiskFreeSpaceEx("C:\\",
I get the same resoults with GetVolumeInformation(..).
Any clues?
TNX!
ASKER
free and the others are pointers to ULARGE_INTEGER..
ULARGE_INTEGER free;
ULARGE_INTEGER total;
ULARGE_INTEGER totalfree;
GetDiskFreeSpaceEx("C:\\", &free,&tot al,&totalf ree);
ULARGE_INTEGER total;
ULARGE_INTEGER totalfree;
GetDiskFreeSpaceEx("C:\\",
ASKER
Of course! TNX!
One more problem...
Tha data I recive is not correct.. Is "C:\\" right? or am I using my variables wrong?
my code afther I recive the data:
tmp tmp[15];
sprintf(tmp,'\n',free);
m_output.SetSelection(tmp) ;
TNX!
One more problem...
Tha data I recive is not correct.. Is "C:\\" right? or am I using my variables wrong?
my code afther I recive the data:
tmp tmp[15];
sprintf(tmp,'\n',free);
m_output.SetSelection(tmp)
TNX!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
TNX - it works.. but i don't know how to calculate used space - i can't substract two ULARGE_INTEGERs?
And I having some problems with "GetVolumeInformation" too.
-------------------------- ---------- ---------- ---------- --
char type_FS;
DWORD name_length;
DWORD serial_num;
char name;
GetVolumeInformation("C:\\ ",&name,30 ,&serial_n um,&name_l ength,NULL ,&type_FS, 10);
sprintf(tmp,"%d",name);
m_name.ReplaceSel(tmp);
sprintf(tmp,"%d",serial_nu m);
m_serial_num.ReplaceSel(tm p);
sprintf(tmp,"%d",type_FS);
m_FS.ReplaceSel(tmp);
-------------------------- ---------- ---------- ---------- --
All I get are some strange numbers - thoug i should get some characters - at least for drive name and stuff..
My output:
name: 84
serial_num: 185212388
FS_type: 70
I can't make heads or tails from this.. :/
And I having some problems with "GetVolumeInformation" too.
--------------------------
char type_FS;
DWORD name_length;
DWORD serial_num;
char name;
GetVolumeInformation("C:\\
sprintf(tmp,"%d",name);
m_name.ReplaceSel(tmp);
sprintf(tmp,"%d",serial_nu
m_serial_num.ReplaceSel(tm
sprintf(tmp,"%d",type_FS);
m_FS.ReplaceSel(tmp);
--------------------------
All I get are some strange numbers - thoug i should get some characters - at least for drive name and stuff..
My output:
name: 84
serial_num: 185212388
FS_type: 70
I can't make heads or tails from this.. :/