Solved

Getting CD-ROM name

Posted on 1998-07-09
8
257 Views
Last Modified: 2013-12-03
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
Comment
Question by:mauromol
8 Comments
 
LVL 2

Expert Comment

by:WDB
ID: 1409829
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
 

Author Comment

by:mauromol
ID: 1409830
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
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1409831
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:mauromol
ID: 1409832
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
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1409833
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
 

Author Comment

by:mauromol
ID: 1409834
Thanks! Let me know when you do learn something!
0
 

Author Comment

by:mauromol
ID: 1409835
Adjusted points to 250
0
 
LVL 6

Accepted Solution

by:
snoegler earned 250 total points
ID: 1409836
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question