🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #293

Re: backup tape

#293
From: Jamie
Date: Thu, 20 Mar 2008 23:49
62 lines
3538 bytes
akalb wrote:

> 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;
I think you have to open it as Create new file not existing..
  and it should be exclusive mode with write only.. in the
operation.
    Just a thought..

http://webpages.charter.net/jamie_5"
Technical Details
Message-ID: <cLBEj.121$29.85@newsfe07.lga>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!hwmnpeer01.lga!news.highwinds-media.com!hw-filter.lga!newsfe07.lga.POSTED!53ab2750!not-for-mail
References: <a6a404f2-1fde-4dde-80cd-62789e087ff9@t54g2000hsg.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10baee,ae752ad51c21fd26
X-Google-Thread: 1eff96,ae752ad51c21fd26
X-Google-Thread: 1efe10,ae752ad51c21fd26
X-Google-Thread: 14438e,ae752ad51c21fd26
X-Google-Attributes: gid10baee,gid1eff96,gid1efe10,gid14438e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!hwmnpeer01.lga!news.highwinds-media.com!hw-filter.lga!newsfe07.lga.POSTED!53ab2750!not-for-mail
From: Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@charter.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: comp.lang.pascal.delphi.misc,borland.public.delphi.vcl.components.writing.general,borland.public.delphi.vcl.components.writing.win32,borland.public.delphi.nativeapi.win32
Subject: Re: backup tape
References: <a6a404f2-1fde-4dde-80cd-62789e087ff9@t54g2000hsg.googlegroups.com>
In-Reply-To: <a6a404f2-1fde-4dde-80cd-62789e087ff9@t54g2000hsg.googlegroups.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 63
Message-ID: <cLBEj.121$29.85@newsfe07.lga>
NNTP-Posting-Host: fjjkfhidgfkchkdgilngghopjifekail
X-Complaints-To: abuse@charter.net
X-Trace: meohkjfdkiefkjamgmoeimofopipoaimlmifcipbbncmloppfjjkfhidgfkchkdglhjfgdkjajaokojflepinpciaalfgocoanmkpmklelbdeddgfedhcngdgkogglfcahdfmkfnbalpodil
NNTP-Posting-Date: Thu, 20 Mar 2008 15:42:16 MST
Date: Thu, 20 Mar 2008 18:49:25 -0500