Cstring curdiskno; // the disk symbol of the current video.
Cstring totaldisksize; // The total size of the current ephemeral Disk
Cstring freedisksize; // The current video disk and remaining space
Char cname [4 * m_imaxcount] = {0 };
Char sdiskpath [4 * m_imaxcount] = {0 };
Getmodulefilename (null, cname, sizeof (cname); // get the current runProgramPath
Cstring ssettingfile;
Ssettingfile. Format ("% s", cname );
Ssettingfile = ssettingfile. Left (ssettingfile. reversefind ('//'));
Ssettingfile = ssettingfile + "//" + "setting. ini ";
// Obtain the full path of the configuration file. The drive letter of the portable disk is saved in setting. ini.
Getprivateprofilestring ("disk", "path", null, sdiskpath, sizeof (sdiskpath), ssettingfile );
// Obtain the drive letter from the configuration file
Char diskname [4];
Diskname [0] = sdiskpath [0];
Diskname [1] = sdiskpath [1];
Diskname [2] = sdiskpath [2];
Diskname [3] = '/0 ';
Ularge_integer lpuse;
Ularge_integer lptotal;
Ularge_integer lpfree;
Getdiskfreespaceex (diskname, & lpuse, & lptotal, & lpfree );
// Obtain the total capacity, used space, and remaining space of the diskname drive.
Totaldisksize. Format ("total space: % 4.2fgb", lptotal. quadpart/1024.0/1024.0/1024.0 );
Freedisksize. Format ("available space: % 4.2fgb", lpfree. quadpart/1024.0/1024.0/1024.0 );
Curdiskno. Format ("Current Disk: % s", sdiskpath );
The content of the Setting. ini file is as follows:
[Package]
Time = 1
[Disk]
Path = E :/
Then the diskname above is E: // get the space size of the E disk. Here, the setting. ini file is placed in the directory of the execution file.