Solved

Associating CD Drive Letters to Manufacturer strings

Posted on 2000-04-03
8
547 Views
Last Modified: 2010-04-04
I'm using several thirdparty ActiveX controls in my application in combination with Delphi's TMediaPlayer VCL.

What I need to do is figure out which Drive letters are associated with the CDWriter in a persons computer. The activeX control I use will give me the manufacturer (say Yamaha) and model number (ex: CRW6416SX) but not the drive letter it's associated with.

Does anyone know how I would associate the two?

John
0
Comment
Question by:zitt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 3

Expert Comment

by:ckaneta
ID: 2684361
from the peanut gallery:


function TForm1.FindFirstCDROM: shortstring;
var  AList: TStringList; Counter: integer;
 begin
  Result := 'no CDROM present';
  AList := TStringList.Create;
  ListDrives(AList);
  for Counter := 0 to AList.Count-1 do
    if GetDriveType(PChar(Alist.Strings[Counter])) = DRIVE_CDROM then
      Result := Alist.Strings[Counter]
 end;
procedure TForm1.ListDrives(Strings: TStringList);
const BufSize = 256;
var Buffer,P : PChar;
 begin
  GetMem(Buffer, BufSize);
  try
   Strings.BeginUpdate;
   try
    Strings.Clear;
    if GetLogicalDriveStrings(BufSize, Buffer) <> 0 then begin
     P := Buffer;
     while P^ <> #0 do begin
      Strings.Add(P);
      Inc(P, StrLen(P) + 1);
     end;
    end;
   finally
    Strings.EndUpdate;
   end;
  finally
   FreeMem(Buffer, BufSize);
  end;
 end;
0
 

Author Comment

by:zitt
ID: 2684715
Thankyou,

I already had a list of the CDROM drives.

What I need now is to associate each drive letter with the manufacturer and model of the cddrive.

Example:
F: = Kenwood 72x TrueSpin
G: = Yamaha CRW6416SX

John
0
 
LVL 4

Accepted Solution

by:
jeurk earned 200 total points
ID: 2690034
Hello,
it depends under which system you are.
fo 98 you can read it from the registry:
I don't have a 98 handy to test for this.
that's all I have for the moment. it's a hard question...

here is a sample code that shows you how to read from the registry :

the key is to search for 'CurrentDriveLetterAssignment'

-------------------------
UNIT Unit1;

INTERFACE

USES
     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
     StdCtrls;

TYPE
     TForm1 = CLASS(TForm)
          Button1: TButton;
          Memo1: TMemo;
          PROCEDURE Button1Click(Sender: TObject);
     private
          { Private declarations }
     public
          { Public declarations }
     END;

VAR
     Form1: TForm1;

IMPLEMENTATION

USES registry;

{$R *.DFM}

PROCEDURE TForm1.Button1Click(Sender: TObject);
VAR
     //partitionInfo: STRING;
     partKeys, keyNames: TStringList; //stores on which drives the patitions are
     regInfo, keyInfo, driveInfo: tregistry;
     tempKeyString: STRING; //the key of the drive we are currently looking at
     i, j: integer;
BEGIN
     //we get some partitions info
     //get all the partitions info on ide drives
     regInfo := tregistry.create;
     regInfo.RootKey := HKEY_LOCAL_MACHINE;
     //partitionInfo := '';

     //     we take a look at the ide drives
     IF regInfo.keyExists('Enum\ESDI') THEN
     BEGIN
          regInfo.OpenKey('Enum\ESDI', False);
          IF regInfo.hasSubKeys THEN
          BEGIN
               //the different drives
               partKeys := TStringList.Create;
               //the key names
               keyNames := TStringList.Create;

               //we get the drive names
               regInfo.GetKeyNames(partKeys);
               //for each drive
               FOR i := 0 TO partKeys.count - 1 DO
               BEGIN
                    keyInfo := tregistry.create;
                    keyInfo.RootKey := HKEY_LOCAL_MACHINE;
                    keyInfo.OpenKey('Enum\ESDI\' + partKeys[i], False);
                    //we get the drive key
                    keyInfo.GetKeyNames(keyNames);
                    //we open the drive key
                    //a drive can be described more then once
                    //I think (it's a presumption) that the right key is the one
                    //that contain the IDEMaster key
                    //if you have more infos, mail me, thanks
                    //check out which drive key has the IDEMaster key
                    FOR j := 0 TO keyNames.Count - 1 DO
                    BEGIN
                         driveInfo := tregistry.create;
                         driveInfo.RootKey := HKEY_LOCAL_MACHINE;
                         IF driveInfo.OpenKey('Enum\ESDI\' + partKeys[i] + '\' + keyNames[j], False) THEN
                         BEGIN
                              //we read the Value
                              IF driveInfo.ValueExists('IDEMaster') THEN
                              BEGIN
                                   tempKeyString := driveInfo.readString('CurrentDriveLetterAssignment');
                                   memo1.Lines.Add('Disque '+IntToStr(i)+' Avec idemaster :'+tempKeyString);
                                   //we found the right key
                                   //break;
                              end
                              else
                              begin
                                   tempKeyString := driveInfo.readString('CurrentDriveLetterAssignment');
                                   memo1.Lines.Add('Disque '+IntToStr(i)+'Sans idemaster :'+tempKeyString);
                              end;
                         end;
                         driveInfo.Free;
                    END;
                    keyInfo.Free;
               END;
               partKeys.Free;
               keyNames.Free;
          END;
     END;
END;
END.
-------------------------


for NT for example, your activeX is looking for his info here :
scan all the entries in
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi
even if it's an atapi device you will find it there.
look all the entries
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\Scsi Port 1\Scsi Bus 0\Target Id 0\Logical Unit Id 0
check if type is CdRomPeripheral
identifier is for me 'LG      CD-ROM CRD-8480C1.04'

I'll look some more at this.
here is a link that you'll like :
Hello,
it depends under which system you are.
fo 98 you can read it from the registry:
I don't have a 98 handy to test for this.
that's all I have for the moment. it's a hard question...

here is a sample code that shows you how to read from the registry :

the key is to search for 'CurrentDriveLetterAssignment'

-------------------------
UNIT Unit1;

INTERFACE

USES
     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
     StdCtrls;

TYPE
     TForm1 = CLASS(TForm)
          Button1: TButton;
          Memo1: TMemo;
          PROCEDURE Button1Click(Sender: TObject);
     private
          { Private declarations }
     public
          { Public declarations }
     END;

VAR
     Form1: TForm1;

IMPLEMENTATION

USES registry;

{$R *.DFM}

PROCEDURE TForm1.Button1Click(Sender: TObject);
VAR
     //partitionInfo: STRING;
     partKeys, keyNames: TStringList; //stores on which drives the patitions are
     regInfo, keyInfo, driveInfo: tregistry;
     tempKeyString: STRING; //the key of the drive we are currently looking at
     i, j: integer;
BEGIN
     //we get some partitions info
     //get all the partitions info on ide drives
     regInfo := tregistry.create;
     regInfo.RootKey := HKEY_LOCAL_MACHINE;
     //partitionInfo := '';

     //     we take a look at the ide drives
     IF regInfo.keyExists('Enum\ESDI') THEN
     BEGIN
          regInfo.OpenKey('Enum\ESDI', False);
          IF regInfo.hasSubKeys THEN
          BEGIN
               //the different drives
               partKeys := TStringList.Create;
               //the key names
               keyNames := TStringList.Create;

               //we get the drive names
               regInfo.GetKeyNames(partKeys);
               //for each drive
               FOR i := 0 TO partKeys.count - 1 DO
               BEGIN
                    keyInfo := tregistry.create;
                    keyInfo.RootKey := HKEY_LOCAL_MACHINE;
                    keyInfo.OpenKey('Enum\ESDI\' + partKeys[i], False);
                    //we get the drive key
                    keyInfo.GetKeyNames(keyNames);
                    //we open the drive key
                    //a drive can be described more then once
                    //I think (it's a presumption) that the right key is the one
                    //that contain the IDEMaster key
                    //if you have more infos, mail me, thanks
                    //check out which drive key has the IDEMaster key
                    FOR j := 0 TO keyNames.Count - 1 DO
                    BEGIN
                         driveInfo := tregistry.create;
                         driveInfo.RootKey := HKEY_LOCAL_MACHINE;
                         IF driveInfo.OpenKey('Enum\ESDI\' + partKeys[i] + '\' + keyNames[j], False) THEN
                         BEGIN
                              //we read the Value
                              IF driveInfo.ValueExists('IDEMaster') THEN
                              BEGIN
                                   tempKeyString := driveInfo.readString('CurrentDriveLetterAssignment');
                                   memo1.Lines.Add('Disque '+IntToStr(i)+' Avec idemaster :'+tempKeyString);
                                   //we found the right key
                                   //break;
                              end
                              else
                              begin
                                   tempKeyString := driveInfo.readString('CurrentDriveLetterAssignment');
                                   memo1.Lines.Add('Disque '+IntToStr(i)+'Sans idemaster :'+tempKeyString);
                              end;
                         end;
                         driveInfo.Free;
                    END;
                    keyInfo.Free;
               END;
               partKeys.Free;
               keyNames.Free;
          END;
     END;
END;
END.
-------------------------


for NT for example, your activeX is looking for his info here :
scan all the entries in
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi
even if it's an atapi device you will find it there.
look all the entries
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\Scsi Port 1\Scsi Bus 0\Target Id 0\Logical Unit Id 0
check if type is CdRomPeripheral
identifier is for me 'LG      CD-ROM CRD-8480C1.04G

here is a link you'll like :
http://www.geocities.com/SiliconValley/Byte/7125/

why do you need that letter association ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:jeurk
ID: 2690037
sorry, I pasted my texte twice.

what you want to do is something I wanted to since a long time for drives.
I would like to make a list of all the logical drives and tell on which hard disk they are...
0
 

Author Comment

by:zitt
ID: 2690363
I'll look into your code. Thanks!

The reason I need this kind of info, is because my program, CDMaster32 (http://www.zittware.com/cdmaster32.html) now has AudioCD Burning capablity.

If a user creates an AudioCD using my software, I'd want to transfer the data back to the local CD database so the information appears there.

The CDWriter software, only knows the Drive manufacturer... my CDDatabase only knows the drive by drive letter.

John
0
 

Author Comment

by:zitt
ID: 2697453
jeurk,

Thanks. While your code wouldn't work for my system... It pointed me in the right direction.

On my system, The CDROM devices are under 'Enum\SCSI'.

Also, this solution only works for Win9x.

I didn't see a way for NT to do the same thing. IE the registery is missing the "CurrentDriveLetterAssignment" entry.

John
0
 
LVL 4

Expert Comment

by:jeurk
ID: 2699581
yups, that's true, esdi is for the IDE hard drives and scsi for the scsi hard drives and the cdrom's...
but they must be a way because easy cd creator is doing it for example...
I hadd not emough time to investivate that...
If you find the answer I would appreciate that you tell it to me...
knipjo@hotmail.com, thanks.

-John ;)
0
 

Author Comment

by:zitt
ID: 2700789
BTW: on my system, even my IDE LS-120 was listed in the SCSI area.

I doubt we'll every find some real MS documentation to give us a real answer to this problem.

John
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

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