Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Misc > Re: backup tape
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 6018 of 6154
Post > Topic >>

Re: backup tape

by Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@[EMAIL PROTECTED] > Mar 20, 2008 at 06:49 PM

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,
>                            @[EMAIL PROTECTED]
>                            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"
 




 1 Posts in Topic:
Re: backup tape
Jamie <jamie_ka1lpa_no  2008-03-20 18:49:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 3:15:10 CDT 2008.