Solved

Getting CD-ROM name

Posted on 1998-07-09
8
253 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is it possible to use a scroll bar to view records in a form? 7 42
MSDN Subscription - Azure and NFP's 3 65
Is COM supported from Apache 1 45
What is MicroStrategy.NET? 2 58
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

895 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

15 Experts available now in Live!

Get 1:1 Help Now