A customer asked me an interesting question yesterday. Can you tell the difference between a CD-ROM and DVD-ROM drive in InstallShield? I had never had the need to do this, so I looked into it.
It appears that InstallShield will tell you if it’s a CD/DVD-type drive, but it does not distinguish between a CD or DVD drive. For example, you can use GetValidDrivesList in InstallScript to get the list of drives on the system. Here are the parameters:
GetValidDrivesList(listID, nDriveType, nMinDriveSpace);
listID – Returns a list of valid drive letters. The string list identified by listID must already have been initialized by a call to ListCreate.
nDriveType – Specifies the type of drive to search for. Can be one of the following values:
- -1 – Searches for all drive types.
- FIXED_DRIVE – Searches only for fixed drives.
- REMOTE_DRIVE – Searches only for remote drives. Remote drives are generally located on a network.
- REMOVEABLE_DRIVE – Searches only for removeable drives. Floppy drives are considered to be removeable drives.
- CDROM_DRIVES – Searches only for CD-ROM drives.
nMinDriveSpace – Specifies the minimum amount of disk space in bytes that must be free on the drive to allow the drive to be included in the return list.
Since GetValidDrivesList does not distinguish between the CD and DVD drives, another option would be to create a Managed Code Custom Action in C# or VB.NET.
Here is a code snippet using the ManagementObjectSearcher class:
ManagementObjectSearcher mgmtObjects = new ManagementObjectSearcher(“Select * from Win32_CDROMDrive”);
foreach (var item in mgmtObjects.Get())
string strDrive = String.Format(“Drive Letter – \t”, item[“Drive”]);
string strName = String.Format(“Name – \t”,item[“Name”]);
In the example, strName will equate to something like this:
“PIONEER DVD-RW DVR-116D”
To use the output, you would have to probably look for CD or DVD in the string to determine the difference between the drives.
Try this out and see how it works for you.