Talk About Network



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 Components Misc > tape backup
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 238 of 240
Post > Topic >>

tape backup

by akalb <akalb.sia@[EMAIL PROTECTED] > Mar 21, 2008 at 05:49 AM

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;




 1 Posts in Topic:
tape backup
akalb <akalb.sia@[EMAI  2008-03-21 05:49:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Tue May 13 18:51:29 CDT 2008.