Ads 468x60px

Smaller time frame always follow the bigger time frame. It's better wait be patience to enter in position than risk with BIG SL. Having strong trading discipline and taking losses when necessary is a sign of serious trading approach
Subscribe:

Labels

Saturday, August 11, 2012

DETECTING CD-ROM DISC AND OTHER DISK CHANGE USING SERIAL NUMBERS


A simple way to find out if a disc (or disk) was changed is to check its volume serial number. For example, you can use the following function to get the volume serial number of a disc. If your CD-ROM drive name is E:, "GetDiskVolSerialID( 'E' )" will return the serial number we're looking for. You can then store this number in your program and compare it to the serial number returned by the next call to "GetDiskVolSerialID()" function. If they are different, you can safely assume that the disc was changed.


function GetDiskVolSerialID(
  cDriveName : char ) : DWord;
var
  dwTemp1,
  dwTemp2 : DWord;
begin
  GetVolumeInformation(
    PChar( cDriveName + ':' ),
    Nil,
    0,
    @Result,
    dwTemp2,
    dwTemp2,
    Nil,
    0
    );
end;
Listing #1 : Delphi code. Download diskvol (0.29 KB).
If need to display the serial number as it's displayed by most original DOS and Windows programs, simply convert the number returned by "GetDiskVolSerialID()" to a hex string: 
MessageDlg(
  'Serial number: ' +
  Format( '%X', [ GetDiskVolSerialID( 'E' ) ] ),
  mtInformation, [mbOk], 0 );
Listing #2 : Delphi code. Download diskvol2 (0.24 KB).

comments