Thread View: comp.lang.pascal.delphi.components.misc
1 messages
1 total messages
Started by akalb
Fri, 21 Mar 2008 12:49
tape backup
Author: akalb
Date: Fri, 21 Mar 2008 12:49
Date: Fri, 21 Mar 2008 12:49
54 lines
3059 bytes
3059 bytes
how can I write a file over a tape backup
I use the procedure below to get the handle of the tape device, but I
don't know how can I write a file over the tape media. Is there anyone
can help me, please ???
I have found the "write" procedure below but I don' know how can I use
it.
Best regards,
Kalbert
//------------------------------------------------------------------------------
// open the tape drive e get the Handle
//------------------------------------------------------------------------------
function TForm1.OpenDrive:THandle;
var
TapeHandle : THandle;
Security : TSecurityAttributes;
begin
Security.nLength := SizeOf(TSecurityAttributes);
Security.bInheritHandle := FALSE;
Security.lpSecurityDescriptor := nil;
TapeHandle := CreateFile(PChar('\\.\TAPE0'),
GENERIC_READ OR GENERIC_WRITE,
FILE_SHARE_READ OR FILE_SHARE_WRITE,
@SECURITY,
OPEN_EXISTING,
0,
0);
if TapeHandle=INVALID_HANDLE_VALUE then
result := 0
else
result := TapeHandle;
end;
procedure TForm1.Write(iBuffer:Pointer; iBufLen:DWORD);
var
TapeHandle : THandle;
lBytesWritten : DWord;
begin
TapeHandle := OpenDrive;
if not WriteFile(TapeHandle,iBuffer^,iBufLen,lBytesWritten,nil) then
if lBytesWritten <> iBufLen then
ShowMessage('WriteFile only wrote '+IntToStr(lBytesWritten)+'
bytes when'+IntToStr(iBufLen)+' bytes were requested')
else
raise Exception.Create('WriteFile returned an error, code
was'+IntToStr(GetLastError()));
end;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads