Einzelnen Beitrag anzeigen

shifter

Registriert seit: 2. Jan 2005
175 Beiträge
 
Delphi 2007 Enterprise
 
#21

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.

  Alt 10. Nov 2005, 15:28
Hi,

das schein langsam zu funktionieren.
Speichern kann ich jetzt auf band, und bei lesen bkomme ich nicht das was ich gespeichert habe.

ich wwrde dir mal posten wie die beiden routinen aussehen.

Write
Delphi-Quellcode:
Var buf : Array [0..512] of Byte;
    re : dWord;
    str : TMemoryStream;
    bow : dWord;
    lcm : pointer;
begin

TapeHandle := OPENDRIVE;

str := TMemoryStream.Create;
str.LoadFromFile('C:\mt.exe');
str.Position :=0;
lcm := nil;
bow := 0;

WriteTapeMark( TapeHandle, 0, 1, False );
WriteFile( TapeHandle, str.memory, str.Size, bow, lcm );

showmessage(inttostr(bow));

str.Free;
closedrive;
und Read
Delphi-Quellcode:
Var bow : dword;
    bwr : dword;
    lcm : pointer;
    buf : pointer;
    outf : Thandle;
    total : dword;
begin
  TapeHandle := OPENDRIVE;

  Security.nLength := SizeOf( TSecurityAttributes );
  Security.bInheritHandle := False;
  Security.lpSecurityDescriptor := nil;

// SetTapePosition( TapeHandle,2, 0,1,0, False);

  lcm := nil;
  buf := VirtualAlloc( lcm, 512, MEM_COMMIT,PAGE_READWRITE );

  outf := CreateFile('C:\Temp\mt-test.exe',GENERIC_WRITE,0,
              @Security,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

  ReadFile( TapeHandle, buf, 512, bow,nil );

  bow := 1;
  total := 0;
  While bow>0 do begin
    ReadFile( TapeHandle, buf, 512, bow,nil );
    if bow>0 then WriteFile( outf, buf, bow, bwr, nil);
    inc( total, bow );
  End;

  closehandle(outf);
  showmessage(inttostr(total));
  closedrive;
Da bekomme ich am ende noch ein speicher error.
Ich bin mir aber nicht ganz sicher ob das mit dem speicher reservierung ganz ok ist.


Ich werde es auf jeden fall noch weiter quellen.

gruss
seba
  Mit Zitat antworten Zitat