The GetSystemDirectory function retrieves the path of the system directory. The system directory contains such files as dynamic-link libraries, drivers, and font files. UINT GetSystemDirectory( LPTSTR lpBuffer, // address of buffer for system directory UINT uSize // size of directory buffer );
UINT GetSystemWindowsDirectory( LPTSTR lpBuffer, // buffer to receive directory name UINT uSize // size of name buffer );
LPTSTR lpBuffer, // address of buffer for system directory
UINT uSize // size of directory buffer
);
LPTSTR lpBuffer, // buffer to receive directory name
UINT uSize // size of name buffer
);
GetSystemDirectory(m_SysDir,128);
static char path[_MAX_PATH];
/* Save current drive. */
curdrive = _getdrive();
/* If we can switch to the drive, it exists. */
for( drive = 1; drive <= 26; drive++ )
{
if( !_chdrive( drive ) )
{
char cMyDrive[_MAX_PATH];
ch=drive + 'A' - 1;
CString str;//str中保存盘符
str.Format("%c",ch);
}
}
{
CString str;
CString driveDesc;
char driveName[] = "A:\\";
char driveLetter = 'A';
long bits = 1;
SHFILEINFO sfi;
UINT flags = SHGFI_DISPLAYNAME;
int size = sizeof(drives) * 8;
for (int i=0; i<size; i++)
{
driveName[0] = driveLetter;
driveDesc.Format("Drive (%c:)", driveLetter);
if (SHGetFileInfo(driveName, 0, &sfi, sizeof(sfi), flags))
driveDesc = sfi.szDisplayName;
if (drives & bits)
{
///this drive exist
bits = bits << 1;
driveLetter += 1;
}
} }