Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

Getting CD-ROM name

Hello.
How can I get my CD-ROM drive name?
i.e., I would like to get the manufacturer name (Pioneer) and model name (DR-U12X) for my k: CD-ROM drive...
Many programs do that, but I don't know how!
Please help!
0
mauromol
Asked:
mauromol
1 Solution
 
WDBCommented:
First open the Cd Device

MICOPENPARMS mciOpenParms;

/** OPEN AND INITIALIZE CD AUDIO  **/
      mciOpenParms.lpstrDeviceType="cdaudio";

      if(dwReturn = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE |
MCI_OPEN_ELEMENT,(DWORD)(LPVOID)&(mciOpenParms)))
      {
                  //report error
      }

Then use mciOPenParms.wDeviceID and call auxGetDeviceCaps()

AUXCAPS ac;
auxGetDevCaps(mciOPenParms.wDeviceID,&ac,sizeof(AUXCAPS));

Now you can get the following information from ac

typedef struct {
    WORD      wMid;
    WORD      wPid;
    MMVERSION vDriverVersion;
    CHAR      szPname[MAXPNAMELEN];
    WORD      wTechnology;
    WORD      wReserved1;
    DWORD     dwSupport;
} AUXCAPS;
 
Members
wMid

Manufacturer identifier for the device driver for the auxiliary audio device. Manufacturer identifiers are defined in Manufacturer and Product Identifiers.

wPid

Product identifier for the auxiliary audio device. Currently, no product identifiers are defined for auxiliary audio devices.

vDriverVersion

Version number of the device driver for the auxiliary audio device. The high-order byte is the major version number, and the low-order byte is the minor version number.

szPname

Product name in a null-terminated string.

wTechnology

Type of the auxiliary audio output:

AUXCAPS_AUXIN

Audio output from auxiliary input jacks.

AUXCAPS_CDAUDIO

Audio output from an internal CD-ROM drive.

wReserved1

Padding.

dwSupport

Describes optional functionality supported by the auxiliary audio device.

AUXCAPS_LRVOLUME

Supports separate left and right volume control.

AUXCAPS_VOLUME

Supports volume control.

If a device supports volume changes, the AUXCAPS_VOLUME flag will be set. If a device supports separate volume changes on the left and right channels, both AUXCAPS_VOLUME and the AUXCAPS_LRVOLUME will be set.



 



0
 
mauromolAuthor Commented:
In this way I can get information about the name of an auxiliary device (such as SB16 Aux: Line-in). However, the DeviceID returned by MCI is different from the ID used by aux functions!
(on my system, using the ID returned by MCI_Open, auxGetDevCaps.szPname is "SB16 Aux: MIDI Synth [220]"!).

I would need to get the manufacturer name and model of the CD-ROM drive! These info are shown in Start | Settings | Control Panel | System under CD-ROM section (I'm talking about W95).
0
 
piano_boxerCommented:
You can read this information from the registry under
HKEY_LOCAL_MACHINE\Enum\SCSI

Under the all SCSI devices (also ATAPI CD-ROM driver) have its own sub key.

You need to enum all the subkeys two levels down, and look to the class of the device to determine if its a CD-ROM drive.

I have a TOSHIBA CDROM drive so there is a subkey called: TOSHIBA_CD-ROM_XM-6202B_1

Use regedit to se what it looks like.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
mauromolAuthor Commented:
Are these keys located in the same place under Windows 98/NT?

I noticed that in this section of my registry there are listed also some peripherals I installed once and then removed. Is there a way to recognize the "active" peripherals from "inactive" ones?
0
 
piano_boxerCommented:
Hmmmm, I cant check the registry on NT right now (only installed on work), but I'll look into it on monday.

Sure there must be a way to determine if the entry is currently active. I'll look into that as well.
0
 
mauromolAuthor Commented:
Thanks! Let me know when you do learn something!
0
 
mauromolAuthor Commented:
Adjusted points to 250
0
 
snoeglerCommented:
I have written a function which i needed for some system checking in an 'Install' program.You
have to pass the device class to 'devClass' (in your case 'cdrom', case insensitive) and you
can iterate over 'nr' until the function returns FALSE. Only the currently used configuration is
checked, not any 'dead' devices having an entry in the registry but not used.
You have to include 'winreg.h' and the standard MFC CString class, but it should be no problem
to convert this to 'char[]' arrays. If you like, just post me (alexander.berthold@rol3.com) a
dummy mail to get your email adress  and i will send you this function in a sample application
or you copy the code from below:

BOOL      GetDeviceInfo(int nr,
                                const CString& devClass,
                                CString& devDesc,
                                CString& manufacturer,
                                CString* prealdevClass=NULL,
                                CString* psubkey=NULL)
{
      LONG      okay;
      int            nEnum,itemFound=0;      // itemFound counts up until 'nr'(arg) is reached
      HKEY      hKeyMain,hKeyEnum,hKeyDevice;
      CString      temp;
      char      subkeyMain[256];
      char      hardwareKey[256];
      char      className[256],deviceDesc[256],manufacturerName[256];
      DWORD      vType,cbSize;

      // Get dynamic configuration(actual) key, see registry for details
      okay=::RegOpenKeyEx(HKEY_DYN_DATA,"Config Manager\\Enum",0,KEY_ALL_ACCESS,&hKeyMain);
      if(okay!=ERROR_SUCCESS) return FALSE;
      for(nEnum=0;;nEnum++) {
            okay=::RegEnumKey(hKeyMain,nEnum,subkeyMain,127);
            if(okay!=ERROR_SUCCESS) return FALSE;
            temp.Format("Config Manager\\Enum\\%s",subkeyMain);
            okay=::RegOpenKeyEx(HKEY_DYN_DATA,temp,0,KEY_ALL_ACCESS,&hKeyEnum);
            if(okay!=ERROR_SUCCESS) continue;

            cbSize      =sizeof(hardwareKey)-1; // terminating '\0';
            okay=::RegQueryValueEx(hKeyEnum,"HardWareKey",NULL,&vType,(LPBYTE)hardwareKey,&cbSize);
            if(okay!=ERROR_SUCCESS) {
                  ::RegCloseKey(hKeyEnum);
                  continue;
            }
            temp.Format("Enum\\%s",hardwareKey);
            if(psubkey!=NULL) (*psubkey)=temp;
            okay=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,temp,0,KEY_ALL_ACCESS,&hKeyDevice);
            if(okay!=ERROR_SUCCESS) {
                  ::RegCloseKey(hKeyEnum);
                  continue;
            }
            // retrieve device class of the device which is currently tested
            cbSize      =sizeof(className)-1;
            okay=::RegQueryValueEx(hKeyDevice,"Class",NULL,&vType,(LPBYTE)className,&cbSize);
            if(okay!=ERROR_SUCCESS) {
                  ::RegCloseKey(hKeyDevice);
                  ::RegCloseKey(hKeyEnum);
                  continue;
            }
            // if devClass is empty, then return all devices
            if(devClass.GetLength()!=0) {
                  if(devClass.CompareNoCase(className)!=0) {
                        ::RegCloseKey(hKeyDevice);
                        ::RegCloseKey(hKeyEnum);
                        continue;
                  }
            }
            cbSize      =sizeof(deviceDesc)-1;
            okay=::RegQueryValueEx(hKeyDevice,"DeviceDesc",NULL,&vType,(LPBYTE)deviceDesc,&cbSize);
            if(okay!=ERROR_SUCCESS) {
                  ::RegCloseKey(hKeyDevice);
                  ::RegCloseKey(hKeyEnum);
                  continue;
            }
            cbSize      =sizeof(manufacturerName)-1;
            okay=::RegQueryValueEx(hKeyDevice,"Manufacturer",NULL,&vType,(LPBYTE)manufacturerName,&cbSize);
            if(okay!=ERROR_SUCCESS)
                  manufacturerName[0]='\0';

            if(itemFound==nr) {
                  if(prealdevClass!=NULL) (*prealdevClass)=className;
                  manufacturer=manufacturerName;
                  devDesc=deviceDesc;
            }
            ::RegCloseKey(hKeyDevice);
            ::RegCloseKey(hKeyEnum);
            if(itemFound==nr) return TRUE;
            itemFound++;
      }
      return FALSE;
}

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now