EraserThread.pas
上传用户:wanyu_2000
上传日期:2021-02-21
资源大小:527k
文件大小:3k
源码类别:

DVD

开发平台:

Delphi

  1. {-----------------------------------------------------------------------------
  2.  Unit Name: EraserThread
  3.  Author:    Paul Fisher / Andrew Semack
  4.  Purpose:   Thread class for disk formatting and erasing
  5.  History:
  6. -----------------------------------------------------------------------------}
  7. unit EraserThread;
  8. interface
  9. uses
  10.   Windows, Classes, HandledThread, Device, DeviceTypes, SCSIUnit,
  11.   SCSIDefs, SCSITypes, Resources;
  12. type
  13.   TEraserThread = class(THandledThread)
  14.   private
  15.     FInfoRecord: PCDBurnerInfo;
  16.     FBurnSettings: TBurnSettings;
  17.     FGLBA: Integer;
  18.     FOnCDStatus: TCDStatusEvent;
  19.     FOnCopyStatus: TCopyStatusEvent;
  20.     FOnBufferProgress: TCDBufferProgressEvent;
  21.     FOnFileBufferProgress: TCDFileBufferProgressEvent;
  22.     FOnBufferStatus: TCDBufferStatusEvent;
  23.     FOnWriteStatusEvent: TCDWriteStatusEvent;
  24.     FDefaults: TScsiDefaults;
  25.     function GetBurnerInfo: TCDBurnerInfo;
  26.   protected
  27.     procedure Execute; override;
  28.     procedure FormatDisk;
  29.     property BurnerInfo: TCDBurnerInfo read GetBurnerInfo;
  30.   public
  31.     procedure Erase;
  32.     constructor Create(InfoRecord: PCDBurnerInfo);
  33.     destructor Destroy; override;
  34.     property BurnSettings: TBurnSettings read FBurnSettings write FBurnSettings;
  35.     property GLBA: Integer read FGLBA write FGLBA default 0;
  36.     property OnCDStatus: TCDStatusEvent read FOnCDStatus write FOnCDStatus;
  37.     property OnCopyStatus: TCopyStatusEvent read FOnCopyStatus write
  38.       FOnCopyStatus;
  39.     property OnBufferProgress: TCDBufferProgressEvent read FOnBufferProgress
  40.       write FOnBufferProgress;
  41.     property OnFileBufferProgress: TCDFileBufferProgressEvent read
  42.       FOnFileBufferProgress write FOnFileBufferProgress;
  43.     property OnBufferStatus: TCDBufferStatusEvent read FOnBufferStatus write
  44.       FOnBufferStatus;
  45.     property OnWriteStatusEvent: TCDWriteStatusEvent read FOnWriteStatusEvent
  46.       write FOnWriteStatusEvent;
  47.   end;
  48. implementation
  49. { TBurnerThread }
  50. procedure TEraserThread.Erase;
  51. begin
  52.   Resume;
  53. end;
  54. constructor TEraserThread.Create(InfoRecord: PCDBurnerInfo);
  55. begin
  56.   inherited Create(True); // already created suspended
  57.   Priority := TThreadPriority(tpTimeCritical); // Set Priority Level
  58.   FreeOnTerminate := True; // Thread Free Itself when terminated
  59.   FInfoRecord := InfoRecord;
  60. end;
  61. destructor TEraserThread.Destroy;
  62. begin
  63.   inherited;
  64. end;
  65. function TEraserThread.GetBurnerInfo: TCDBurnerInfo;
  66. begin
  67.   Result := FInfoRecord^;
  68. end;
  69. procedure TEraserThread.FormatDisk;
  70. begin
  71.   if Assigned(FOnCDStatus) then
  72.     FOnCDStatus(resErasingData);
  73.   SCSIBlankCD(BurnerInfo, FBurnSettings.EraseType, FGLBA, fDefaults);
  74.   if Assigned(FOnCDStatus) then
  75.     FOnCDStatus(resEraseFinish);
  76. end;
  77. procedure TEraserThread.Execute;
  78. begin
  79.   try
  80.     FormatDisk;
  81.   except
  82.     HandleException;
  83.   end;
  84. end;
  85. end.