[fpc-pascal]Getting disk label and serial numbers

www www2mail at ezmail.ru
Thu Aug 8 21:01:06 CEST 2002


RG> I am currently trying to write a catalog program for my archive CD-ROM's
RG> and I can not find a working method of a) getting the volume label and
RG> b) getting the serial number.

this function get unique CDId
probable work with win32 :)

uses Windows,MMSystem;

Function GetCDId(DeviceName: PChar; Buf: PChar; BufSize:Integer):Boolean;
 Var OpenParm: TMCI_Open_Parms;
     InfoParm: TMCI_Info_Parms;
     FError : Integer;
     FDeviceID: Word;
Begin
   GetCDId:=false;
   FillChar(OpenParm, SizeOf(TMCI_Open_Parms), 0);
   OpenParm.dwCallback := 0;
   Integer(OpenParm.lpstrDeviceType) := MCI_DEVTYPE_CD_AUDIO {'CDAudio'};
   OpenParm.lpstrElementName := DeviceName;
   FError := mciSendCommand (  0,
                               mci_Open, MCI_OPEN_ELEMENT or
                               MCI_OPEN_TYPE_ID or mci_Wait or
                               mci_Open_Type or
                               mci_Open_Shareable,
                               Longint(@OpenParm));
   FDeviceID := OpenParm.wDeviceID;
   if FError = 0 then begin
    FillChar(InfoParm, sizeof(TMCI_Info_Parms), 0);
    InfoParm.lpstrReturn := Buf;
    InfoParm.dwRetSize:=BufSize;
    FError:=mciSendCommand(FDeviceId, MCI_INFO, MCI_INFO_MEDIA_IDENTITY, longint(@InfoParm));
    GetCDId:=FError=0;
   end;
   MCISendCommand(FDeviceID, MCI_CLOSE, 0, 0);
end;

-- 
С уважением,
 www                          mailto:www2mail at ezmail.ru





More information about the fpc-pascal mailing list