pipelogix wrote:
After looking over the MFC sample code and not seeing any differences in how I was handling the actually cancel, I looked into it further.
The MFC sample uses StarBurn...TrackAtOnceFromTree, I was using StarBurn..SessionAtOnce.
Can you not use StarnBurn_CdvdBurnerGrabber_Cancel to cancel SessionAtOnce?
I have just tested canceling when burning in SAO. It works fine.
But you see, Cancel can't stop the burning process immidiatelly. It should wait until buffer will become empty. It takes over 5 seconds. For small images cancel will not work, when all the data was sent to the buffer.
Here is a code I have tested SAO.
Code:
{-----------------------------------------------------------------------------}
{ }
{ Copyright (c) Rocket Division Software 2001-2005. All rights reserved. }
{ }
{ Module Name: }
{ }
{ SessionAtOnceFromFile.dpr }
{ }
{ Abstract: }
{ }
{ SessionAtOnceFromFile is StarBurn sample application. }
{ ISO9660/Joliet/sound image recording to CD/DVD in Session-At-Once mode. }
{ }
{ [ This is external sample that has StarBurn toolkit in a separate DLL ] }
{ }
{ Author: }
{ }
{ Anton A. Kolomyeytsev }
{ }
{ Alexey Popov }
{ }
{ Environment: }
{ }
{ Windows 95/98/ME/NT/2K/XP/2003 UserMode only }
{ }
{ Notes: }
{ }
{ Known bugs/Illegal behavior: }
{ }
{ ToDo: }
{ }
{-----------------------------------------------------------------------------}
Program SessionAtOnceFromFile;
{$APPTYPE CONSOLE}
Uses
Windows, SysUtils, Forms, StarBurn, SamplesTools;
{=============================================================================}
Var
l__ULONG__Status : DWORD;
l__CHAR__VendorID : Packed Array[ 1..1024 ] Of Char;
l__CHAR__ProductID : Packed Array[ 1..1024 ] Of Char;
l__CHAR__ProductRevisionLevel : Packed Array[ 1..1024 ] Of Char;
l__ULONG__BufferSizeInUCHARs,
l__ULONG__CurrentReadSpeed,
l__ULONG__MaximumReadSpeed,
l__ULONG__CurrentWriteSpeed,
l__ULONG__MaximumWriteSpeed : DWORD;
l__PVOID__CdvdBurnerGrabber : Pointer;
l__EXCEPTION_NUMBER : EXCEPTION_NUMBER;
l__CHAR__ExceptionText : Packed Array[ 1..1024 ] Of Char;
l__CDB_FAILURE_INFORMATION : CDB_FAILURE_INFORMATION;
l__DISC_INFORMATION : DISC_INFORMATION;
l__DISC_TYPE : DISC_TYPE;
l__STRING : String;
l__BOOLEAN__IsSendOPCSuccessful,
l__BOOLEAN__IsBUPSupported,
l__BOOLEAN__IsBUPEnabled,
l__BOOLEAN__IsTrackAtOnce,
l__BOOLEAN__IsSessionAtOnce,
l__BOOLEAN__IsDiscAtOncePQ,
l__BOOLEAN__IsDiscAtOnceRawPW,
l__BOOLEAN__IsTestWrite : Boolean;
l__DISC_LAYOUT : DISC_LAYOUT;
l__LONG__Index : Integer;
l__TRACK_INFORMATION : TRACK_INFORMATION;
l__HANDLE : THANDLE;
l__ULONG__FileSizeLow : DWORD;
l__ULONG__FileSizeHigh : DWORD;
l__LARGE_INTEGER__FileSizeInUCHARs : LARGE_INTEGER;
dwThreadId : DWORD;
Function CancelThread( P : Pointer):DWORD stdcall;
Begin
OutputDebugString('CancelThread() : ENTERed!');
Sleep(15*1000);
OutputDebugString('CancelThread() : Canceling...!');
StarBurn_CdvdBurnerGrabber_Cancel(l__PVOID__CdvdBurnerGrabber);
OutputDebugString('CancelThread() : EXITing');
End;
Begin
{ Main application entry called by OS loader }
l__ULONG__Status := ERROR_GEN_FAILURE;
l__ULONG__BufferSizeInUCHARs := 0;
l__PVOID__CdvdBurnerGrabber := NIL;
l__BOOLEAN__IsTrackAtOnce := FALSE;
l__BOOLEAN__IsSessionAtOnce := FALSE;
l__BOOLEAN__IsDiscAtOncePQ := FALSE;
l__BOOLEAN__IsDiscAtOnceRawPW := FALSE;
l__BOOLEAN__IsTestWrite := TRUE; // Assume test write by default
WriteLn('SessionAtOnceFromFile: ENTERed for ',ParamCount,' argument(s)');
//
// Check are there enough input parameters
//
If ParamCount < 4 Then Begin
WriteLn( 'SessionAtOnceFromFile: EXITing with failure!!!' );
WriteLn( 'SessionAtOnceFromFile: SCSI address' );
WriteLn( 'SessionAtOnceFromFile: Example: SessionAtOnceFromFile.exe 0 0 1 0' );
//
// Return invalid status
//
Halt(ERROR_INVALID_PARAMETER);
End;
ZeroMemory(
@l__CHAR__ExceptionText[1],
sizeof( l__CHAR__ExceptionText )
);
WriteLn(
Format(
'SessionAtOnceFromFile: %d MBs of cache will be used during burn process',
[
CACHE_SIZE_IN_MBS
])
);
WriteLn(Format(
'SessionAtOnceFromFile: Probing SCSI address %d:%d:%d:%d for CD/DVD burner device... ',
[
SafeStrToInt(ParamStr( 1 )),
SafeStrToInt(ParamStr( 2 )),
SafeStrToInt(ParamStr( 3 )),
SafeStrToInt(ParamStr( 4 ))
])
);
//
// Start processing cleanup
//
Try
//
// Try to initialize StarBurn
//
l__EXCEPTION_NUMBER := StarBurn_UpStart();
//
// Check for success
//
if l__EXCEPTION_NUMBER <> EN_SUCCESS then
begin
WriteLn(
Format(
'SessionAtOnceFromFile: StarBurn_UpStart() failed, exception %ld',
[
Integer( l__EXCEPTION_NUMBER )
]
)
);
//
// Get out of here
//
Raise Exception.Create('Error');
end;
//
// Try to construct CD/DVD burner, passing 0 as cache size will make the toolkit allocate default amount of
// cache memory
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_Create(
l__PVOID__CdvdBurnerGrabber,
PCHAR( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION,
@SamplesCallback,
NIL,
SafeStrToInt(ParamStr( 1 )),
SafeStrToInt(ParamStr( 2 )),
SafeStrToInt(ParamStr( 3 )),
SafeStrToInt(ParamStr( 4 )),
0 // = DEFAULT_CACHE_SIZE_IN_MBS
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(
Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_Create() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PAnsiChar(@l__CHAR__ExceptionText[1])
]
)
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
//
// Prepare data buffers
//
ZeroMemory(
PAnsiChar(@l__CHAR__VendorID[1]),
sizeof( l__CHAR__VendorID )
);
ZeroMemory(
PAnsiChar(@l__CHAR__ProductID[1]),
sizeof( l__CHAR__ProductID )
);
ZeroMemory(
PAnsiChar(@l__CHAR__ProductRevisionLevel[1]),
sizeof( l__CHAR__ProductRevisionLevel )
);
//
// Try to get CD/DVD burner information
//
StarBurn_CdvdBurnerGrabber_GetDeviceInformation(
l__PVOID__CdvdBurnerGrabber,
PCHAR( @l__CHAR__VendorID[1] ),
PCHAR( @l__CHAR__ProductID[1] ),
PCHAR( @l__CHAR__ProductRevisionLevel[1] ),
l__ULONG__BufferSizeInUCHARs
);
WriteLn('Ok!');
WriteLn(
Format(
'SessionAtOnceFromFile: Found CD/DVD device "%s" - "%s" - "%s" with %d UCHARs of cache',
[
PCHAR( @l__CHAR__VendorID[1]),
PCHAR( @l__CHAR__ProductID[1]),
PCHAR( @l__CHAR__ProductRevisionLevel[1]),
l__ULONG__BufferSizeInUCHARs
])
);
WriteLn( 'SessionAtOnceFromFile: Probing supported write modes... ' );
//
// Try to probe supported write modes
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_ProbeSupportedWriteModes(
l__PVOID__CdvdBurnerGrabber,
PCHAR ( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION,
l__BOOLEAN__IsTrackAtOnce,
l__BOOLEAN__IsSessionAtOnce,
l__BOOLEAN__IsDiscAtOncePQ,
l__BOOLEAN__IsDiscAtOnceRawPW
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_ProbeSupportedWriteModes() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PAnsiChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
WriteLn('OK!');
WriteLn(
Format(
'SessionAtOnceFromFile: Track-At-Once: %s, Session-At-Once: %s, Disc-At-Once PQ: %s, Disc-At-Once raw P-W: %s',
[
YesNo(l__BOOLEAN__IsTrackAtOnce),
YesNo(l__BOOLEAN__IsSessionAtOnce),
YesNo(l__BOOLEAN__IsDiscAtOncePQ),
YesNo(l__BOOLEAN__IsDiscAtOnceRawPW)
])
);
//
// Check do we have Session-At-Once supported
//
If l__BOOLEAN__IsSessionAtOnce = FALSE
Then Begin
WriteLn( 'SessionAtOnceFromFile: Session-At-Once is unsupported!!!' );
//
// Get out of here
//
Raise Exception.Create('Error');
End;
WriteLn( 'SessionAtOnceFromFile: Testing unit ready... ' );
//
// Try to test unit ready
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_TestUnitReady(
l__PVOID__CdvdBurnerGrabber,
PCHAR ( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(
Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_TestUnitReady() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PAnsiChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
WriteLn( 'Ok!' );
WriteLn( 'SessionAtOnceFromFile: Getting BUP (Buffer Underrun Protection) support... ' );
//
// Try to get BUP here
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_GetBUP(
l__PVOID__CdvdBurnerGrabber,
PCHAR ( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION,
l__BOOLEAN__IsBUPEnabled,
l__BOOLEAN__IsBUPSupported
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(
Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_GetBUP() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PAnsiChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
WriteLn('Ok!');
WriteLn(
Format(
'SessionAtOnceFromFile: BUP (Buffer Underrun Protection) Enabled: %s, Supported: %s',
[
YesNo(l__BOOLEAN__IsBUPEnabled),
YesNo(l__BOOLEAN__IsBUPSupported)
])
);
//
// Check if the BUP supported try to enable it
//
If l__BOOLEAN__IsBUPSupported = TRUE Then Begin
WriteLn( 'SessionAtOnceFromFile: Enabling BUP (Buffer Underrun Protection)... ' );
//
// Try to set BUP status
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_SetBUP(
l__PVOID__CdvdBurnerGrabber,
PCHAR ( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION,
TRUE
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_SetBUP() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PAnsiChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
WriteLn( 'OK!' );
End;
WriteLn( 'SessionAtOnceFromFile: Setting maximum supported CD/DVD speeds... ' );
//
// Try to set maximum supported CD/DVD speeds here
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_SetSpeeds(
l__PVOID__CdvdBurnerGrabber,
PCHAR ( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION,
CDVD_SPEED_IS_KBPS_MAXIMUM,
CDVD_SPEED_IS_KBPS_MAXIMUM
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(
Format(
'SessionAtOnceFromFile: WARNING! StarBurn_CdvdBurnerGrabber_SetSpeeds() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PAnsiChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
//Raise Exception.Create('Error');
End;
WriteLn( 'Ok!');
WriteLn( 'SessionAtOnceFromFile: Getting current CD/DVD speeds... ' );
//
// Try to get current read/write speeds to show what we'll have
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_GetSpeeds(
l__PVOID__CdvdBurnerGrabber,
PCHAR( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION,
l__ULONG__CurrentReadSpeed,
l__ULONG__MaximumReadSpeed,
l__ULONG__CurrentWriteSpeed,
l__ULONG__MaximumWriteSpeed
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(
Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_GetSpeeds() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
WriteLn('Ok!');
WriteLn(
Format(
'SessionAtOnceFromFile: Current read speed %d KBps (%d maximum)',
[
l__ULONG__CurrentReadSpeed,
l__ULONG__MaximumReadSpeed
])
);
WriteLn(
Format(
'SessionAtOnceFromFile: Current write speed %d KBps (%d maximum)',
[
l__ULONG__CurrentWriteSpeed,
l__ULONG__MaximumWriteSpeed
])
);
WriteLn( 'SessionAtOnceFromFile: Getting track information... ' );
//
// Try to read track information
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_GetTrackInformation(
l__PVOID__CdvdBurnerGrabber,
PCHAR( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION,
TRACK_NUMBER_INVISIBLE,
@l__TRACK_INFORMATION
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_GetTrackInformation() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
WriteLn('Ok!');
WriteLn(
Format(
'SessionAtOnceFromFile: Track Blank: %s, NWA valid: %s, free LBs %d, NWA %d, track number %d',
[
YesNo(l__TRACK_INFORMATION.m__BOOLEAN__IsBlank),
YesNo(l__TRACK_INFORMATION.m__BOOLEAN__IsNextWritableAddressValid),
l__TRACK_INFORMATION.m__LONG__FreeLBs,
l__TRACK_INFORMATION.m__LONG__NextWritableAddress,
l__TRACK_INFORMATION.m__UCHAR__TrackNumber
]
)
);
WriteLn( 'SessionAtOnceFromFile: Getting disc information... ' );
//
// Try to read disc information
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_GetDiscInformation(
l__PVOID__CdvdBurnerGrabber,
PCHAR( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION,
@l__DISC_INFORMATION
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(
Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_GetDiscInformation() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
//
// Try to get disc type
//
l__DISC_TYPE := StarBurn_CdvdBurnerGrabber_GetInsertedDiscType( l__PVOID__CdvdBurnerGrabber );
If l__DISC_INFORMATION.m__BOOLEAN__IsErasable Then
l__String := 'Yes'
Else
l__String := 'No';
WriteLn('Ok!');
WriteLn(
Format(
'SessionAtOnceFromFile: Disc erasable: %s, Disc status: 0x%02X, Last session status: 0x%02X, Disc type: %d',
[
l__String,
l__DISC_INFORMATION.m__UCHAR__DiscStatus,
l__DISC_INFORMATION.m__UCHAR__LastSessionStatus,
DWORD( l__DISC_TYPE )
])
);
//
// Check is this test burn, if yes we do not need to send OPC as some recorders do not like sending OPC in
// simulation mode
//
If l__BOOLEAN__IsTestWrite = FALSE Then Begin
WriteLn( 'SessionAtOnceFromFile: Sending OPC (Optimum Power Calibration)... ' );
//
// Set flag OPC was successful, it will be reset in case of exception
//
l__BOOLEAN__IsSendOPCSuccessful := TRUE;
//
// Try to send OPC
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_SendOPC(
l__PVOID__CdvdBurnerGrabber,
PCHAR( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn( 'Failed!' );
//
// Reset the flag OPC was successful
//
l__BOOLEAN__IsSendOPCSuccessful := FALSE;
(*
WriteLn(Format(
'SessionAtOnceFromFile: WARNING! StarBurn_CdvdBurnerGrabber_SendOPC() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PChar(@l__CHAR__ExceptionText[1])
])
);
*)
//
// Do not leave as failing to send OPC is not critical error
//
//
// Get out of here
//
//__leave;
End;
//
// Check was OPC successful
//
If l__BOOLEAN__IsSendOPCSuccessful = TRUE Then Begin
WriteLn('OK!');
End;
WriteLn('SessionAtOnceFromFile: Writing the stuff to the CD/DVD disc >>>' );
End
Else Begin
WriteLn( 'SessionAtOnceFromFile: Skipping send OPC (Optimum Power Calibration) in test mode... OK!' );
WriteLn( 'SessionAtOnceFromFile: Writing the stuff (simulating) to the CD/DVD disc >>>' );
End;
CreateThread(NIL,0,@CancelThread,NIL,0,dwThreadId);
//
// Reset last written percent to zero
//
g__LARGE_INTEGER__LastWrittenPercent.QuadPart := 0;
//
// Prepare disc layout
//
ZeroMemory(
@l__DISC_LAYOUT,
sizeof( l__DISC_LAYOUT )
);
l__String := 'c:\audio\1.wav';
//
// Copy current command line entry
//
CopyMemory(
@l__DISC_LAYOUT.m__DISC_LAYOUT_ENTRY[ 1 ].m__CHAR__TrackName[1],
PChar(l__String),
Length(l__String),
);
l__String := 'c:\audio\2.wav';
//
// Copy current command line entry
//
CopyMemory(
@l__DISC_LAYOUT.m__DISC_LAYOUT_ENTRY[ 2 ].m__CHAR__TrackName[1],
PChar(l__String),
Length(l__String),
);
l__String := 'c:\audio\3.wav';
//
// Copy current command line entry
//
CopyMemory(
@l__DISC_LAYOUT.m__DISC_LAYOUT_ENTRY[ 3 ].m__CHAR__TrackName[1],
PChar(l__String),
Length(l__String),
);
//
// Update number of tracks
//
l__DISC_LAYOUT.m__LONG__NumberOfEntries := 3;
//
// Try to write the ISO/sound image to the disc as CDROM XA (MODE2 Form1) CDDA (CD digital audio)
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_SessionAtOnce(
l__PVOID__CdvdBurnerGrabber,
PCHAR( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION,
@l__DISC_LAYOUT,
FALSE, // TRUE -- MODE2/Form1 vs FALSE -- MODE1, would be IGNORED for RAW images
l__BOOLEAN__IsTestWrite,
TRUE, // Next session allowed
WRITE_REPORT_DELAY_IN_SECONDS,
BUFFER_STATUS_REPORT_DELAY_IN_SECONDS
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(
Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_SessionAtOnce() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
WriteLn( 'SessionAtOnceFromFile: Ejecting the disc... ' );
//
// Try to eject the disc
//
l__EXCEPTION_NUMBER :=
StarBurn_CdvdBurnerGrabber_Eject(
l__PVOID__CdvdBurnerGrabber,
PCHAR( @l__CHAR__ExceptionText[1] ),
sizeof( l__CHAR__ExceptionText ),
l__ULONG__Status,
@l__CDB_FAILURE_INFORMATION
);
//
// Check for success
//
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
WriteLn(
Format(
'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_Eject() failed, exception %d, status %d, text "%s"',
[
Integer(l__EXCEPTION_NUMBER),
l__ULONG__Status,
PChar(@l__CHAR__ExceptionText[1])
])
);
//
// Get out of here
//
Raise Exception.Create('Error');
End;
//
// Set status to good one
//
l__ULONG__Status := ERROR_SUCCESS;
WriteLn( 'OK!' );
Except
End;
//
// Check was CdvdBurnerGrabber allocated
//
If l__PVOID__CdvdBurnerGrabber <> NIL Then
//
// Free allocated memory
//
StarBurn_Destroy( l__PVOID__CdvdBurnerGrabber );
//
// Uninitalize StarBurn, do not care about execution status
//
StarBurn_DownShut();
If l__ULONG__Status = ERROR_SUCCESS Then
WriteLn( 'SessionAtOnceFromFile: EXITing with success' )
Else
WriteLn( 'SessionAtOnceFromFile: EXITing with failure, Status = ', l__ULONG__Status);
//
// Return execution status
//
Halt(l__ULONG__Status);
End.