Article View: comp.lang.pascal.delphi.components.misc
Article #9tape backup
From: 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;
Technical Details
Message-ID:
<201f0e6e-2f95-48bd-874d-ec771bdba1f4@59g2000hsb.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!59g2000hsb.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 109d99,c05a906d6083b5a7,start X-Google-Thread: 14b4c1,c05a906d6083b5a7,start X-Google-Thread: 11ae7b,c05a906d6083b5a7,start X-Google-Attributes: gid109d99,gid14b4c1,gid11ae7b,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!59g2000hsb.googlegroups.com!not-for-mail From: akalb <akalb.sia@gmail.com> Newsgroups: comp.lang.pascal.delphi.components.misc,borland.public.delphi.vcl.components.using.win32,borland.public.delphi.language.delphi.general Subject: tape backup Date: Fri, 21 Mar 2008 05:49:23 -0700 (PDT) Organization: http://groups.google.com Lines: 55 Message-ID: <201f0e6e-2f95-48bd-874d-ec771bdba1f4@59g2000hsb.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 1206103763 8721 127.0.0.1 (21 Mar 2008 12:49:23 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 21 Mar 2008 12:49:23 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 59g2000hsb.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)