I have something to ask
on your finddevice sample, I am adding a StarBurn_GetDeviceNameByDeviceAddress, to get drive letter.
then its stuck on procedure ZeroMemory, its says that something like unknown variable (@1__CHAR__DeviceName), but if I close it, it will run. after I compile and run it for second time, my computer get slower, after third time it freeze or error in memory.
please check my code. I use finddevice in a different unit that will pass a string to my main unit.
Code:
unit Unit4;
interface
uses Windows, SysUtils, StarBurn, SamplesTools, Messages;
function finddevice : string;
implementation
var kata : string;
Procedure FindCallback(
Const p__CALLBACK_NUMBER : CALLBACK_NUMBER;
Const p__PVOID__CallbackContext,
p__PVOID__CallbackSpecial1,
p__PVOID__CallbackSpecial2 : Pointer
) stdcall;
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__CHAR__DeviceName : Packed Array[ 1..1024 ] Of Char;
l__ULONG__BufferSizeInUCHARs : 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__PSCSI_DEVICE_ADDRESS : PSCSI_DEVICE_ADDRESS;
l__BOOLEAN__IsCDRRead,
l__BOOLEAN__IsCDERead,
l__BOOLEAN__IsDVDROMRead,
l__BOOLEAN__IsDVDRRead,
l__BOOLEAN__IsDVDRAMRead,
l__BOOLEAN__IsTestWrite,
l__BOOLEAN__IsCDRWrite,
l__BOOLEAN__IsCDEWrite,
l__BOOLEAN__IsDVDRWrite,
l__BOOLEAN__IsDVDRAMWrite,
l__BOOLEAN__IsDVDPLUSRWRead,
l__BOOLEAN__IsDVDPLUSRRead,
l__BOOLEAN__IsDVDPLUSRWWrite,
l__BOOLEAN__IsDVDPLUSRWrite : Boolean;
Begin
l__ULONG__Status := ERROR_GEN_FAILURE;
l__ULONG__BufferSizeInUCHARs := 0;
l__PVOID__CdvdBurnerGrabber := NIL;
// Process depending of callback number.
Case p__CALLBACK_NUMBER Of
// if this is FIND_DEVICE
CN_FIND_DEVICE: Begin
// Prepare data buffer
ZeroMemory(
@l__CHAR__ExceptionText,
sizeof( l__CHAR__ExceptionText )
);
l__PSCSI_DEVICE_ADDRESS := PSCSI_DEVICE_ADDRESS( p__PVOID__CallbackSpecial1 );
// Start processing cleanup
Try
// 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,
l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__PortID,
l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__BusID,
l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__TargetID,
l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__LUN,
0 // == DEFAULT_CACHE_SIZE_IN_MBS
);
// Check for success
If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
// Get out of here
Raise Exception.Create('Error');
End;
//to get device name
{ZeroMemory(
@1__CHAR__DeviceName,
sizeof(1__CHAR__DeviceName)
);}
l__EXCEPTION_NUMBER :=
StarBurn_GetDeviceNameByDeviceAddress(
l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__PortID,
l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__BusID,
l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__TargetID,
l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__LUN,
PCHAR( @l__CHAR__DeviceName )
);
// Prepare data buffers
ZeroMemory(
@l__CHAR__VendorID,
sizeof( l__CHAR__VendorID )
);
ZeroMemory(
@l__CHAR__ProductID,
sizeof( l__CHAR__ProductID )
);
ZeroMemory(
@l__CHAR__ProductRevisionLevel,
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
);
// Get CdvdBurnerGrabber device extended information
StarBurn_CdvdBurnerGrabber_GetSupportedMediaFormats(
l__PVOID__CdvdBurnerGrabber,
l__BOOLEAN__IsCDRRead,
l__BOOLEAN__IsCDERead,
l__BOOLEAN__IsDVDROMRead,
l__BOOLEAN__IsDVDRRead,
l__BOOLEAN__IsDVDRAMRead,
l__BOOLEAN__IsTestWrite,
l__BOOLEAN__IsCDRWrite,
l__BOOLEAN__IsCDEWrite,
l__BOOLEAN__IsDVDRWrite,
l__BOOLEAN__IsDVDRAMWrite
);
// Get CdvdBurnerGrabber device extended information for DVD+R(w)
StarBurn_CdvdBurnerGrabber_GetSupportedMediaFormatsEx(
l__PVOID__CdvdBurnerGrabber,
l__BOOLEAN__IsDVDPLUSRWRead,
l__BOOLEAN__IsDVDPLUSRRead,
l__BOOLEAN__IsDVDPLUSRWWrite,
l__BOOLEAN__IsDVDPLUSRWrite
);
//disini masukkan ke database
kata := kata +'~'+ 'INSERT INTO tb_device VALUES ('+
inttostr(l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__PortID) +','+
inttostr(l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__BusID) +','+
inttostr(l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__TargetID)+','+
inttostr(l__PSCSI_DEVICE_ADDRESS^.m__UCHAR__LUN) +','+
quotedstr(PCHAR( @l__CHAR__VendorID[1])) +','+
quotedstr(PCHAR( @l__CHAR__ProductID[1])) +','+
quotedstr(PCHAR( @l__CHAR__ProductRevisionLevel[1]))+','+
inttostr(l__ULONG__BufferSizeInUCHARs) +','+
YesNo[l__BOOLEAN__IsCDRRead] +','+
YesNo[l__BOOLEAN__IsCDRWrite] +','+
YesNo[l__BOOLEAN__IsCDERead] +','+
YesNo[l__BOOLEAN__IsCDEWrite] +','+
YesNo[l__BOOLEAN__IsDVDROMRead] +','+
YesNo[l__BOOLEAN__IsDVDRRead] +','+
YesNo[l__BOOLEAN__IsDVDRWrite] +','+
YesNo[l__BOOLEAN__IsDVDRAMRead] +','+
YesNo[l__BOOLEAN__IsDVDRAMWrite] +','+
YesNo[l__BOOLEAN__IsDVDPLUSRRead] +','+
YesNo[l__BOOLEAN__IsDVDPLUSRWrite] +','+
YesNo[l__BOOLEAN__IsDVDPLUSRWRead] +','+
YesNo[l__BOOLEAN__IsDVDPLUSRWWrite]+','+
quotedstr(PCHAR( @l__CHAR__DeviceName))+')';
Except
End;
// Check was CdvdBurnerGrabber allocated
If l__PVOID__CdvdBurnerGrabber <> NIL Then
// Free allocated memory
StarBurn_Destroy( l__PVOID__CdvdBurnerGrabber );
End;
End; // Case
End; // Call-back function
function finddevice : string;
Var
l__LONG__NumberOfCdvdDevices : LongInt;
l__EXCEPTION_NUMBER : EXCEPTION_NUMBER;
Begin
kata := '';
// Try to initialize StarBurn
l__EXCEPTION_NUMBER := StarBurn_UpStart();
// Check for success
if l__EXCEPTION_NUMBER <> EN_SUCCESS then
begin
// Get out of here
Raise Exception.Create('Error');
end;
// Try to list all CD/DVD devices in the system
l__LONG__NumberOfCdvdDevices :=
StarBurn_FindDevice(
SCSI_DEVICE_RO_DIRECT_ACCESS,
FALSE,
@FindCallback,
NIL
);
// Uninitalize StarBurn, do not care about execution status
StarBurn_DownShut();
finddevice := kata;
end;
end.
and one thing, I download debugview from
www.sysinternal.com, its work for version 4.1.0, but for version 4.7.3 it doesnt work, its only show few text.
thank you for your help.