Solved

Associating CD Drive Letters to Manufacturer strings

Posted on 2000-04-03
8
529 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
  • 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

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

Suggested Solutions

Title # Comments Views Activity
System restore point 4 78
code issue 8 85
Making delphi communicate with a c# service 16 73
LAN or WAN ? 11 63
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 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

21 Experts available now in Live!

Get 1:1 Help Now