🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.opentoolsapi
Article #28

tape backup

#28
From: akalb
Date: Thu, 20 Mar 2008 09:54
54 lines
3119 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;
Technical Details
Message-ID: <5af1e6c3-9b2b-40ba-9b00-75a820a21b3b@n77g2000hse.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!n77g2000hse.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10c3df,787968d64e4b793a,start
X-Google-Thread: fdeaa,787968d64e4b793a,start
X-Google-Thread: 112b07,787968d64e4b793a,start
X-Google-Thread: 110b53,787968d64e4b793a,start
X-Google-Attributes: gid10c3df,gidfdeaa,gid112b07,gid110b53,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!n77g2000hse.googlegroups.com!not-for-mail
From: akalb <akalb.sia@gmail.com>
Newsgroups: borland.public.delphi.opentoolsapi,borland.public.delphi.non-technical,borland.public.delphi.vcl.components.writing,it.comp.lang.delphi
Subject: tape backup
Date: Thu, 20 Mar 2008 02:54:57 -0700 (PDT)
Organization: http://groups.google.com
Lines: 54
Message-ID: <5af1e6c3-9b2b-40ba-9b00-75a820a21b3b@n77g2000hse.googlegroups.com>
NNTP-Posting-Host: 81.88.228.52
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1206006898 5835 127.0.0.1 (20 Mar 2008 09:54:58 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 20 Mar 2008 09:54:58 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: n77g2000hse.googlegroups.com; posting-host=81.88.228.52; 
 posting-account=zgwcyAoAAABEwUoL7wC05Kj_fT-ZgLb0
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.12) 
 Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe)