[fpc-pascal]Re:Getting disk label and serial numbers

Yet Another Geek yetanothergeek at yahoo.com
Fri Aug 9 10:25:03 CEST 2002


program cdname;

{ Here is a simple Windows 98 example that
  prints the Drive Letter, Volume name, 
  and SerialNumber of your CDROM drives
  to StdOut ...
 You may need to $IFDEF this to use WideChars on
NT/2000/XP !
}

uses windows;
var 
 DrvStr : string[4];
 pszVolName : array[0..11] of char;
 pdwSerNum, dwMaxFNLen, dwFSysFlags : DWORD;
 pszFSysName : array[0..127] of char;
 DrvChr : Char;
 
begin
  DrvStr := '?:\' + #0; { the '?' is just a
placeholder }
  for DrvChr := 'C' to 'Z' do begin
    DrvStr[1] := DrvChr;
    if ( GetDriveType(@DrvStr[1] ) = DRIVE_CDROM ) 
    and  GetVolumeInformation( 
          @DrvStr[1], @pszVolName[0],
SizeOf(pszVolName),
          @pdwSerNum, dwMaxFNLen,
          dwFSysFlags,
          @pszFSysName, SizeOf(pszFSysName) 
      ) 
    then 
    WriteLn(DrvChr, #9, pszVolName, #9,  pdwSerNum);
  end;
  
  WriteLn('Press Return');
  { pause before closing the DOS window ...}
  ReadLn;
end.

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com




More information about the fpc-pascal mailing list