• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 560
  • Last Modified:

Associating CD Drive Letters to Manufacturer strings

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
zitt
Asked:
zitt
  • 4
  • 3
1 Solution
 
ckanetaCommented:
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
 
zittAuthor Commented:
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
 
jeurkCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jeurkCommented:
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
 
zittAuthor Commented:
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
 
zittAuthor Commented:
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
 
jeurkCommented:
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
 
zittAuthor Commented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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