Solved

Getting CD-ROM name

Posted on 1998-07-09
8
252 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now