CPB Mailing List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Right Drive or Lastdrive ?



Am I really getting the CDROM path or just the last drive??? I can't
tell because they're the same. If I were using drivespace the CDROM
would be in the middle of the PathSet[] array somewhere. Can somebody
using drivespace, or who's CDROM drive is not the last drive, test this
for me? Thanks.

The project constists of a Form, a Button, and  a Label. That's all.
Presumably, if Label1 comes up blank, there's no CDROM drive on the system.

declare in header (Private)>> 
void __fastcall GetCDPath(void);
String PathSet[78];
/*78 = 3 x letters in the alphabet*/

I used a button to call GetCDPath( ) but will eventually use this in
another procedure. Right now I'm just tying to get it to work :-)

void __fastcall TForm1::GetCDPath(void)
{
    /*setup array of drives*/
    Label1->Caption = "";
    int ps = 0;
    DWORD dwSize;
    char *lpDrive, *lpIndex;
    dwSize = GetLogicalDriveStrings(0,NULL);
    lpDrive = new char[dwSize];
    GetLogicalDriveStrings(dwSize, lpDrive);
    lpIndex = lpDrive;
    while (strlen(lpIndex) != 0)
    {
        /*count the drives available*/
	PathSet[ps] = lpIndex;
	++ps;
	lpIndex +=strlen(lpIndex) + 1;
    }
    unsigned int DriveType;
    while (ps > 0)
    /*who is the CDROM*/
    {
	DriveType = GetDriveType(PathSet[ps].c_str());
	--ps;
	switch (DriveType)
    	{
	case DRIVE_CDROM:
        /* ps+1 'cause it jumps into here when ps == the prior drive
	   also, I had changed the case: to DRIVE_FIXED and came
	   up with c:\ so it does appear to work
	*/ 
	    Label1->Caption = PathSet[ps+1].c_str();
	    break;
	default:
	    break;
        }
    }
    delete [] lpDrive;
}

Rick Malik
rmfci@pacbell.net
"Visit the C++ Builder Hobby Pages"
http://home.pacbell.net/rmfci/bcbhp.htm


W Komornicki's Home Page | Main Index | Thread Index