Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Bandlaufwerk / Streamer ansprechen unter Delphi. (https://www.delphipraxis.net/56533-bandlaufwerk-streamer-ansprechen-unter-delphi.html)

shifter 7. Nov 2005 15:14


Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Hi,

ich bin auf der suche nach eine möglichkein ein bandlaufwerk anzusprechen( Read / Save / Format ),
es steht leider nicht sehr viel darüber geschrieben. Ein oder andere artikel habe ich gefunden aber
nichts konkretes.
Es handelt sich hier um SCSI Bandlaufwerke DDS2-4 und SLR wie auch DLT.

Könnt Ihr mir behilflich sein ???

Gruss
seba

Flocke 7. Nov 2005 16:27

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Du kannst das erste Bandlaufwerk wie eine Datei mit dem Dateinamen \\.\tape0 öffnen. Ein-/Ausgabe sollte mit den normalen Funktionen gehen. Es gibt die API-Funktionen MSDN-Library durchsuchenGetTapeParameters, MSDN-Library durchsuchenGetTapePosition, MSDN-Library durchsuchenGetTapeStatus, MSDN-Library durchsuchenSetTapeParameters und MSDN-Library durchsuchenSetTapePosition.

Ein kleines Programm in C das das Tape anspricht habe ich hier gefunden (Basisseite).

shifter 7. Nov 2005 16:35

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
DANKE ERSTMAL FÜR DIE SCHNELLE ANTWORT, WERDE SOFORT CHECKEN !!

DANKE

und gruss
aus W-tal

shifter 7. Nov 2005 21:29

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Da hab ich noch eine Frage / Problemm,
und zwar es geht um die Function GetTapeParameters

So Sieht die in C aus
Code:

DWORD GetTapeParameters(
  HANDLE hDevice,
  DWORD dwOperation,
  LPDWORD lpdwSize,
  LPVOID lpTapeInformation
);
Und so habe ich es umgeschrieben

Delphi-Quellcode:

Var Si : dword;
    ew : dword;
    ti : GMP;
Begin
 
  ...

  ew := GetTapeParameters( TapeHandle, GET_TAPE_MEDIA_INFORMATION, Size, @TI );

  If TI.WriteProtected Then ShowMessage('WriteProtect');

End;
GMP ist
Delphi-Quellcode:
Type
  GMP              = Record
    Capacity       : LongInt;
    Remaining      : LongInt;
    BlockSize      : dWORD;
    PartitionCount : dWORD;
    WriteProtected : Boolean;
  End;
Aber irgend wie Functioniert Das Nicht !!!

Auch wenn ich GMP.Capacity Abfrage oder andere parameter bekomme ich nur sch... aber nicht das
was ich haben will.

Wo hab ich misst gebaut ?

gruss
seba

SirThornberry 7. Nov 2005 21:31

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
wie hast du die Funktion übersetzt? hast du eventuell StdCall vergessen?

Flocke 7. Nov 2005 22:14

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Also die Funktionen für den Tape-Zugriff sind ja in Windows.pas deklariert, allerdings die Strukturen nicht. LARGE_INTEGER ist IMHO ein int64. Hier meine Übersetzung (ungetestet):

Delphi-Quellcode:
type
  PTapeGetMediaParameters = ^TapeGetMediaParameters;
  _TAPE_GET_MEDIA_PARAMETERS = record
    Capacity: int64;
    Remaining: int64;
    BlockSize: DWORD;
    PartitionCount: DWORD;
    WriteProtected: Boolean;
  end;
  {$EXTERNALSYM _TAPE_GET_MEDIA_PARAMETERS}
  TTapeGetMediaParameters = _TAPE_GET_MEDIA_PARAMETERS;
  TAPE_GET_MEDIA_PARAMETERS = _TAPE_GET_MEDIA_PARAMETERS;
  {$EXTERNALSYM TAPE_GET_MEDIA_PARAMETERS}

  PTapeGetDriveParameters = ^TTapeGetDriveParameters;
  _TAPE_GET_DRIVE_PARAMETERS = record
    ECC: Boolean;
    Compression: Boolean;
    DataPadding: Boolean;
    ReportSetmarks: Boolean;
    DefaultBlockSize: DWORD;
    MaximumBlockSize: DWORD;
    MinimumBlockSize: DWORD;
    MaximumPartitionCount: DWORD;
    FeaturesHigh: DWORD;
    EOTWarningZoneSize: DWORD;
  end;
  {$EXTERNALSYM _TAPE_GET_DRIVE_PARAMETERS}
  TTapeGetDriveParameters = _TAPE_GET_DRIVE_PARAMETERS;
  TAPE_GET_DRIVE_PARAMETERS = _TAPE_GET_DRIVE_PARAMETERS;
  {$EXTERNALSYM TAPE_GET_DRIVE_PARAMETERS}
Übrigens ist sicher der ganze Abschnitt "Delphi-Referenz durchsuchenBackup Reference" (ms-help://borland.bds3/fileio/base/backup_reference.htm) bzw. MSDN Startseite für dich interessant.

//EDIT: Typen korrigiert

shifter 7. Nov 2005 23:25

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Ja das ist das,
jetzt sieht es auf jeden fall besser aus !

Danke Flocke !!!!!!!!

shifter 8. Nov 2005 00:17

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Hier ist aber noch ein Hacken !

Wenn ich zb. Anzeigen möchte DefaultBlockSize sollte eingentlich
wert rauskommen mit 512 kommt aber 2, sowie MinimumBlockSize
kommt ein exotisches Wert der grösser ist als MaximumBlockSize der eben so exotisch
erscheint.

gruss
seba

shifter 8. Nov 2005 00:52

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Ich hab's !

Entgültig ist es geschaft.



Problemme hat es gemacht :

LongBool habe ich ersetzt mit Boolean
Packed record mit normalen record

und func. 100%

Danke euch allen

gruss
seba

Flocke 8. Nov 2005 08:49

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Zitat:

Zitat von shifter
LongBool habe ich ersetzt mit Boolean
Packed record mit normalen record

War - wie geschrieben - ungetestet. Ich habe die Typen oben mal angepasst, falls mal jemand danach sucht.

Robert Marquardt 8. Nov 2005 09:35

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
ByteBool statt Boolean ist sicherer.

Flocke 8. Nov 2005 12:35

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Zitat:

Zitat von Robert Marquardt
ByteBool statt Boolean ist sicherer.

Da gebe ich dir Recht, aber ich hab' mich da an das Vorbild "Windows.pas" gehalten - Borland hat auch alles mit dem Typ "Boolean" deklariert.

shifter 8. Nov 2005 23:42

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Also bis jetzt waren das Relativ kleine Problemme, Problemme auf die eine lösung in sicht war. Jetzt bin ich auf ein problemm gestossen wo nichtmal msdn von ms konnte mir helfen.

PrepareTape

Zitat:

TAPE_FORMAT
5L Performs a low-level format of the tape. Currently, only the QIC117 device supports this feature.
Es ist nicht unbedingt das modernste und ich denke kaum einer hat noch solch ein oldtimer.

Ich brauch es für mein Streamer Tandberg Data SLR bis 200GB oder DDS3 und 4 bis 40GB.

Habt Ihr vieleicht eine idee warum wird die PrepareTape Function nicht unterstützt ?
Gibts vieleicht irgend wo eine externe DLL die mann von Delphi aus nutzen kann ?

MfG
Seba

shifter 9. Nov 2005 00:24

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Und noch was,

Wenn der Windows 2K und WXP kann eine sicherung machen auf oben gennanten Laufwerken dann musste das doch funktionieren ohne zusätzlichen DLL's die nicht in System vorhanden sind.
Die Frage bleibt, wie es funktioniert.
Bei msdn bin ich noch gestossen auf msdn eine kleinichkeit, ich weis es aber nicht womit mann das essen kann.

gruss
seba

Flocke 9. Nov 2005 08:13

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
zu 1. Das Band kann wahrscheinlich nicht formatiert werden, ähnlich wie man moderne Festplatten nicht mehr Low-Level-Formatieren sollte. Nimm statt dessen einfach TAPE_ERASE_LONG, dass macht das Band auch leer.

zu 2. Die Seite ist über Treiber, nicht über die Anwendungssoftware.

Schau dir wirklich mal den Link von oben an (http://holistech.co.uk/sw/mt/mt.c) - das ist zwar in C, aber (fast) alle Tape-Kommmandos sind implementiert.

shifter 9. Nov 2005 10:24

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Hallo und Guten Morgen,

danke für deine Antwort, du hast Recht, ich habe es gelöscht und auch hast du Rech mit dem LowLevel. Andere Grosse Software hersteller ( Veritas unc co. ) nutzen auch das nicht mehr.
Ich habe diesen mt.c mir genau angeschaut leider fehlt da BackupWrite, und da komme ich nicht mit zu recht.
Damit habe ich zwei Problemme,

1:
Code:
BOOL BackupWrite(
  HANDLE hFile,
  LPBYTE lpBuffer,
  DWORD nNumberOfBytesToWrite,
  LPDWORD lpNumberOfBytesWritten,
  BOOL bAbort,
  BOOL bProcessSecurity,
  LPVOID* lpContext
);
ich bekomme nirgends wo Informationen wie soll lpContext aufgebaut sein.

2:
Das zweite problemm kommt wenn mann kein C beherst.

Code:
LPBYTE lpBuffer
Hier kommt doch ein Pointer ins Spiel


Ich habe den BackupWrite so varstanden :
Delphi-Quellcode:
...
str  : TMemoryStream;
ou   : dWord;
lpc  : _CONTEXT;

...

BackupWrite( TapeHandle,@str,str.Size, @ou, False, False, @lpc );
Es wird Bemengelt von den Compiler @ou,
Wenn ich aber "ou" ohne "@" reinsetzte ist es wieder o.k.
Und das macht mich irre, ich denke doch wenn es LPBYTE oder LPDWORD in C steht handelt es sich um ein Pointer.
Und das mit dem @lpc klappt auch nicht.


Help

seba

Flocke 9. Nov 2005 10:33

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Du musst natürlich auch beachten, wie die "Übersetzung" in Windows.pas aussieht.

Delphi-Quellcode:
function BackupWrite(hFile: THandle; lpBuffer: PByte; nNumberOfBytesToWrite: DWORD;
  var lpNumberOfBytesWritten: DWORD; bAbort, bProcessSecurity: BOOL; var lpContext: Pointer): BOOL; stdcall;
lpContext ist einfach ein Zeiger, den du Anfangs mit nil initialisieren musst und einfach bei allen weiteren Aufrufen wieder angibst, ohne den Inhalt zu verändern - sonst muss dich dieser Parameter nicht interessieren. Wenn du fertig bist mit dem Schreiben, dann musst du halt BackupWrite noch einmal mit eben diesem Zeiger aufrufen und bAbort auf true setzen - das gibt den Speicher wieder frei. (Steht übrigens alles im PSDK zu BackupWrite)

lpBuffer ist ein Zeiger auf die Daten - in deinem Fall, bei einem TMemoryStream, würdest du hier str.Memory angeben.

shifter 9. Nov 2005 11:12

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Flocke nicht aufregen,

Delphi-Quellcode:
Var str : TMemoryStream;
    ou : dword;
    lcm : pointer;
begin
    TapeHandle := OPENDRIVE;

    str := TMemoryStream.Create;
    str.LoadFromFile('C:\mt.exe');

    lcm := nil;
    ou := 0;

    showmessage(inttostr(str.Size)); // Länge des mt.exe = 23040

    BackupWrite( TapeHandle,str.Memory,str.Size,ou, false,false, lcm );

    showmessage(inttostr(ou));      // Geschriebene länge = 204

    BackupWrite( TapeHandle,str.Memory,str.Size,ou, true,false, lcm );


    str.Free;

    CLOSEDRIVE;
Passiert nichts. Irgend wo mache ich noch fehler.

Andere Frage,

Was ist TapeMark ? Ist das änlich mit cluster auf hdd ?

Gruss
seba

shifter 9. Nov 2005 23:39

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Bei dem MT.EXE SourceCode habe ich folgendes :

Code:
SetTapePosition( tapedrive, TAPE_ABSOLUTE_BLOCK,0,(DWORD)(position & 0xffffffff),
   (DWORD)((position >> 32) & 0xffffffff),FALSE)
Da ich von C nichts verstehe wie kann man es übersetzten?
(DWORD)(position & 0xffffffff)
und
(DWORD)((position >> 32) & 0xffffffff)

Es handelt sich hierbei um
Zitat:

dwOffsetLow
[in] Low-order bits of the block address or count for the position operation specified by the dwPositionMethod parameter.
dwOffsetHigh
[in] High-order bits of the block address or count for the position operation specified by the dwPositionMethod parameter. If the high-order bits are not required, this parameter should be zero.
Gruss
Seba

Flocke 10. Nov 2005 08:00

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Wieso habe ich denn Gestern deine neuen Beiträge nicht mitbekommen :gruebel:

Zitat:

Zitat von shifter
Flocke nicht aufregen,

Delphi-Quellcode:
Var str : TMemoryStream;
    ou : dword;
    lcm : pointer;
begin
    TapeHandle := OPENDRIVE;

    str := TMemoryStream.Create;
    str.LoadFromFile('C:\mt.exe');

    lcm := nil;
    ou := 0;

    showmessage(inttostr(str.Size)); // Länge des mt.exe = 23040

    BackupWrite( TapeHandle,str.Memory,str.Size,ou, false,false, lcm );

    showmessage(inttostr(ou));      // Geschriebene länge = 204

    BackupWrite( TapeHandle,str.Memory,str.Size,ou, true,false, lcm );


    str.Free;

    CLOSEDRIVE;
Passiert nichts. Irgend wo mache ich noch fehler.

Zunächst einmal (war mir vorher gar nicht so aufgefallen) - man benutzt die Funktionen BackupRead und BackupWrite dazu, die eigentlichen Dateien auf der Festplatte auszulesen und zu schreiben, und nicht das Band. Das Band wird einfach mit WriteFile beschrieben und mit ReadFile gelesen.

<Hinzugefügt>
Mit BackupRead liest man nicht nur die reinen Daten einer Datei, sondern alle Streams (z.B. die ACLs, also die Zugriffsrechte). Dabei bekommst du für jeden Stream jeweils eine WIN32_STREAM_ID-Struktur inkl. des Namens und im Anschluss daran die Daten des Streams, deren Größe im Feld Size angegeben ist (evtl. plus Füll-Bytes, um auf 32-Bits auszurichten).

Wenn du also alle Daten, die du mit BackupRead liest, mit BackupWrite wieder schreibst, dann stellst du nicht nur den Inhalt der Datei wieder her sondern auch alle anderen Attribute.
</Hinzugefügt>

Zitat:

Zitat von shifter
Andere Frage,

Was ist TapeMark ? Ist das änlich mit cluster auf hdd ?

Gruss
seba

Mit WriteTapeMark kannst du Markierungen auf das Band schreiben, z.B. den Beginn einer neuen Datei kennzeichnen. Mit SetTapePosition kannst du dann eine bestimmte Markierung gezielt ansteuern.

Zitat:

Zitat von shifter
Bei dem MT.EXE SourceCode habe ich folgendes :

Code:
SetTapePosition( tapedrive, TAPE_ABSOLUTE_BLOCK,0,(DWORD)(position & 0xffffffff),
   (DWORD)((position >&gt; 32) &amp; 0xffffffff),FALSE)
Da ich von C nichts verstehe wie kann man es übersetzten?
(DWORD)(position & 0xffffffff)
und
(DWORD)((position >> 32) & 0xffffffff)

Es handelt sich hierbei um
Zitat:

dwOffsetLow
[in] Low-order bits of the block address or count for the position operation specified by the dwPositionMethod parameter.
dwOffsetHigh
[in] High-order bits of the block address or count for the position operation specified by the dwPositionMethod parameter. If the high-order bits are not required, this parameter should be zero.
Gruss
Seba

(DWORD)(position & 0xffffffff) - die unteren 32 Bits
(DWORD)((position >> 32) & 0xffffffff) - die oberen 32 Bits

Wenn du nur mit Integer arbeitest (für Dateizähler bzw. Dateigröße), dann kannst du für dwOffsetHigh einfach 0 angeben.

Wenn du mit Int64 arbeitest, dann nimm LARGE_INTEGER(Zahl).LowPart und LARGE_INTEGER(Zahl).HighPart

shifter 10. Nov 2005 16:28

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
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

Flocke 10. Nov 2005 17:54

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Stimmen die Daten denn überhaupt nicht überein oder sind sie nur um ~512 Bytes verschoben? Da wäre ein Test mit einer reinen Textdatei vielleicht sinnvoller ;)

Habe hier noch ein paar Grundlagen gefunden.

1. die Datenmenge sollte immer ein Vielfaches der Blockgröße sein (das wird deinen Schreibfehler verursachen)
2. ein FILEMARK schreibt man hinter das Ende der Datei, nicht davor

Ansonsten ist es wohl viel Ausprobieren. Obwohl es mich wirklich interessiert (habe selbst ein Tape), habe ich momentan nicht die Zeit da herumzuexperimentieren...

shifter 10. Nov 2005 18:41

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Also die Datenmenge stimmt zu 100%.

Der fehler an der sache ist TmemoryStream.

Ich habe getestet :

Delphi-Quellcode:

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

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

  WriteFile( outf, str.memory, str.Size, bow, nil);
Und das klappt schon mal nicht. Also es liegt erstmal nicht an den Tape selbst,
es liegt daran die daten von TMemoryStream mittels WriteFile zu speichern.

Da muss ich noch dran feilen.

gruss
seba

shifter 10. Nov 2005 22:40

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Ich gebe schon langsam auf. :wall:

Wenn ich zum testen ein file lade in speicher mittels VirtuallAlloc und BackupRead,
und auf festplatte wieder speichere mit BackupWrite ist alles OK.

Das heist mit dem VirtuallAlloc hat es gecklapt.

Wenn ich aber mit WriteFile auf Band das aufnehmen möchte bekomme ich False als ergebnis von
WriteFile und geschriebene menge = 0.

Wenn ich das gleiche mache aber stat VirtuallAlloc, verwende ich TmemoryStream klapt das mit dem nachbar
und es wird gespeichert auf band. Aber der inchalt ist nicht der der sein soll.

Und so versuche ich aufzunehmen :
Delphi-Quellcode:
Var buf  : Pointer;
    re   : boolean;
    bow  : dword;
    bor  : dword;
    lcm  : pointer;
    inf  : thandle;
begin

  TapeHandle := OPENDRIVE_READ;

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

  SetTapePosition ( TapeHandle, 4, 0, 0,0, False );

  buf := VirtualAlloc( nil, 23040, MEM_COMMIT, PAGE_READWRITE );
  inf := CreateFile('C:\mt.exe',GENERIC_READ,0,
              @Security,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

  lcm := nil;
  BackupRead( inf, buf, 23040, bor, false, false, lcm );
  closedrive;

  tapehandle := opendrive_write;
  lcm := nil;
  re  := WriteFile( TapeHandle, buf, bor, bow, lcm);

// und hier wird es gemeldet das re=FALSE und bow=0

  WriteTapeMark( TapeHandle, 0, 1, False );

  closehandle(inf);
  closedrive;
Help.

seba

Flocke 11. Nov 2005 08:08

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Wieso hast du denn ein CloseDrive hinter dem BackupRead?

... Moment, muss mal eben meinen Rechner neu starten ...
... So, wieder da ...

Du solltest dir angewöhnen, bei API-Funktionen, die fehlschlagen können, ein RaiseLastOsError zu setzen - dann erhälst du nämlich auch eine Fehlermeldung!

Beispiel:
Delphi-Quellcode:
if not WriteFile(TapeHandle, buf, bor, bow, lcm) then
  RaiseLastOsError;

shifter 11. Nov 2005 12:59

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Hallo,

das mit dem CLOSEDRIVE; ist hier aus versehen reingeckommen.
Ich habe RaiseLastOsError eingebaut :

System Error. Code:87. Falsche Parameter

Der Compiler hat nicht gemeckert :gruebel: .

Wenn Ich aber diese funktion stat WriteFile ausführe mit BackupWrite dann ist die welt wieder in ordnung.

Aber mal was anderes,
Wie kann ich zB. aus einem Reserviertem speicher bereich ein Byte mir anzeigen lassen :gruebel:

Also wenn ich speicher Reserviere mit :
Delphi-Quellcode:

Var
   buf  : Pointer;
Begin
   buf := VirtualAlloc( nil, 10, MEM_COMMIT, PAGE_READWRITE );
   ...
   BackupRead( xy, buf, 10, ....
Ich würde einfach gern sehen was er in buf reingeladen hat Byte für Byte.
Da buf ist ein Pointer wie kann ich die Speicher Adresse buf und buf+1, und buf+2 ....
Auslesen ?

Gruss
seba

shifter 11. Nov 2005 13:19

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Und noch was,

wenn ich EraseTape mit dem parameter TAPE_ERASE_SHORT ausführen möchte dann bekomme
ich Fehler meldung Unzulässige Parameter. Das ist erstaunlich da mit einem
Backup Programm kann ich es machen ohne problemme .

gruss
seba

Flocke 11. Nov 2005 13:30

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Zitat:

Zitat von shifter
Hallo,

das mit dem CLOSEDRIVE; ist hier aus versehen reingeckommen.
Ich habe RaiseLastOsError eingebaut :

System Error. Code:87. Falsche Parameter

Der Compiler hat nicht gemeckert :gruebel: .

Die Parameter sind ja auch syntaktisch richtig - wieso sollte der Compiler da meckern?

Zitat:

Zitat von shifter
Wenn Ich aber diese funktion stat WriteFile ausführe mit BackupWrite dann ist die welt wieder in ordnung.

Es muss aber auch mit WriteFile gehen.

Zitat:

Zitat von shifter
Ich würde einfach gern sehen was er in buf reingeladen hat Byte für Byte.
Da buf ist ein Pointer wie kann ich die Speicher Adresse buf und buf+1, und buf+2 ....
Auslesen ?

Deklariere die Variable als PByte (statt Pointer) und trage im Ausdrucksfenster buf^ ein, Anzeige auf hexadezimal stellen und Anzahl Wiederholungen auf ~50.

Flocke 11. Nov 2005 14:45

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Noch was: wie sehen eigentlich die Geräteparameter bei dir aus?
Hier mal meine Liste (OnStream DI-30 ADR):
Code:
GetTapeParameters / GET_TAPE_DRIVE_INFORMATION:
  ECC: Yes
  Compression: No
  DataPadding: Yes
  ReportSetmarks: No
  [color=blue]DefaultBlockSize: 32768
  MaximumBlockSize: 32768
  MinimumBlockSize: 32768[/color]
  MaximumPartitionCount: 1
  FeaturesLow: $1211750
    [ - ] Creates `fixed´ data partitions
    [ - ] Creates `select´ data partitions
    [ - ] Creates `initiator-defined´ partitions
    [ X ] Supports `short erase´ operations
    [color=red][ - ] Supports `long erase´ operations[/color]
    [ X ] Performs erase operations from the beginning-of-partition marker only
    [ - ] Performs immediate erase operations (returns when the erase operation begins)
    [ X ] Returns the maximum capacity of the tape
    [ X ] Returns the remaining capacity of the tape
    [ X ] Supports `fixed-length´ block mode
    [ - ] Supports `variable-length´ block mode
    [ X ] Returns error if tape is `write-enabled´ or `write-protected´
    [ - ] Supports the `end-of-medium´ warning size
    [ X ] Supports hardware error correction
    [ - ] Supports hardware data compression
    [ - ] Supports data padding
    [ - ] Supports setmark reporting
    [ - ] Provides current device-specific block address
    [ X ] Provides current logical block address (and logical tape partition)
    [ - ] Supports setting the `end-of-medium´ warning size
    [ X ] Physically ejects tape on a software eject
    [ - ] Can report if cleaning is required
    [ - ] Can set compression at the beginning-of-partition marker only
  FeaturesHigh: $2474007
    [ X ] Enables and disables the device for further operations
    [ X ] Supports tape tensioning
    [ X ] Enables and disables the tape ejection mechanism
    [ - ] Supports immediate rewind operation
    [ - ] Supports setting the size of a fixed-length logical block or variable-length block mode
    [ - ] Supports immediate load and unload operations
    [ - ] Supports immediate tape tensioning
    [ - ] Supports immediate lock and unlock operations
    [ - ] Enables and disables hardware error correction
    [ - ] Enables and disables hardware data compression
    [ - ] Enables and disables data padding
    [ - ] Enables and disables the reporting of setmarks
    [ - ] Can move to a device specific block address
    [ - ] Can move to a device-specific block address immediately
    [ X ] Can move to a logical block address in a partition
    [ - ] Can move to a logical block address in a partition immediately
    [ X ] Can move to the end-of-data marker in a partition
    [ X ] Can move forward (or backward) a specified number of blocks
    [ X ] Can move forward (or backward) a specified number of filemarks
    [ - ] Can move forward (or backward) to the first occurrence of a specified number of consecutive filemarks
    [ - ] Can move forward (or backward) a specified number of setmarks
    [ - ] Can move forward (or backward) to the first occurrence of a specified number of consecutive setmarks
    [ X ] Can move backward over blocks, filemarks, or setmarks
    [ - ] Supports immediate spacing
    [ - ] Writes setmarks
    [ X ] Writes filemarks
    [ - ] Writes short filemarks
    [ - ] Writes long filemarks
    [ - ] Supports immediate writing of short and long filemarks
    [ - ] Supports tape formatting operations
    [ - ] Supports immediate tape formatting operations
  EOTWarningZoneSize: 0
Interessant hier:
rot Kann kein LONG_ERASE - das geht bei dir ja wohl auch nicht
blau Kann *NUR* Blöcke mit 32K Größe - WriteFile muss immer ein Vielfaches dieser Blockgröße schreiben.

Außerdem: die Typen weiter oben stimmten immer noch nicht, nimm entweder aus der Jedi-ApiLib die Dateien JwaWinBase.pas und JwaWinNT.pas oder nimm diese hier:

Delphi-Quellcode:
const
  GET_TAPE_MEDIA_INFORMATION = 0;
  {$EXTERNALSYM GET_TAPE_MEDIA_INFORMATION}
  GET_TAPE_DRIVE_INFORMATION = 1;
  {$EXTERNALSYM GET_TAPE_DRIVE_INFORMATION}

type
  PTapeGetMediaParameters = ^TTapeGetMediaParameters;
  _TAPE_GET_MEDIA_PARAMETERS = record
    Capacity: int64;
    Remaining: int64;
    BlockSize: DWORD;
    PartitionCount: DWORD;
    WriteProtected: ByteBool;
  end;
  {$EXTERNALSYM _TAPE_GET_MEDIA_PARAMETERS}
  TTapeGetMediaParameters = _TAPE_GET_MEDIA_PARAMETERS;
  TAPE_GET_MEDIA_PARAMETERS = _TAPE_GET_MEDIA_PARAMETERS;
  {$EXTERNALSYM TAPE_GET_MEDIA_PARAMETERS}

  PTapeGetDriveParameters = ^TTapeGetDriveParameters;
  _TAPE_GET_DRIVE_PARAMETERS = record
    ECC: ByteBool;
    Compression: ByteBool;
    DataPadding: ByteBool;
    ReportSetmarks: ByteBool;
    DefaultBlockSize: DWORD;
    MaximumBlockSize: DWORD;
    MinimumBlockSize: DWORD;
    MaximumPartitionCount: DWORD;
    FeaturesLow: DWORD;
    FeaturesHigh: DWORD;
    EOTWarningZoneSize: DWORD;
  end;
  {$EXTERNALSYM _TAPE_GET_DRIVE_PARAMETERS}
  TTapeGetDriveParameters = _TAPE_GET_DRIVE_PARAMETERS;
  TAPE_GET_DRIVE_PARAMETERS = _TAPE_GET_DRIVE_PARAMETERS;
  {$EXTERNALSYM TAPE_GET_DRIVE_PARAMETERS}

// Definitions for FeaturesLow parameter
const
  TAPE_DRIVE_FIXED           = $00000001; {$EXTERNALSYM TAPE_DRIVE_FIXED}
  TAPE_DRIVE_SELECT          = $00000002; {$EXTERNALSYM TAPE_DRIVE_SELECT}
  TAPE_DRIVE_INITIATOR       = $00000004; {$EXTERNALSYM TAPE_DRIVE_INITIATOR}
  TAPE_DRIVE_ERASE_SHORT     = $00000010; {$EXTERNALSYM TAPE_DRIVE_ERASE_SHORT}
  TAPE_DRIVE_ERASE_LONG      = $00000020; {$EXTERNALSYM TAPE_DRIVE_ERASE_LONG}
  TAPE_DRIVE_ERASE_BOP_ONLY  = $00000040; {$EXTERNALSYM TAPE_DRIVE_ERASE_BOP_ONLY}
  TAPE_DRIVE_ERASE_IMMEDIATE = $00000080; {$EXTERNALSYM TAPE_DRIVE_ERASE_IMMEDIATE}
  TAPE_DRIVE_TAPE_CAPACITY   = $00000100; {$EXTERNALSYM TAPE_DRIVE_TAPE_CAPACITY}
  TAPE_DRIVE_TAPE_REMAINING  = $00000200; {$EXTERNALSYM TAPE_DRIVE_TAPE_REMAINING}
  TAPE_DRIVE_FIXED_BLOCK     = $00000400; {$EXTERNALSYM TAPE_DRIVE_FIXED_BLOCK}
  TAPE_DRIVE_VARIABLE_BLOCK  = $00000800; {$EXTERNALSYM TAPE_DRIVE_VARIABLE_BLOCK}
  TAPE_DRIVE_WRITE_PROTECT   = $00001000; {$EXTERNALSYM TAPE_DRIVE_WRITE_PROTECT}
  TAPE_DRIVE_EOT_WZ_SIZE     = $00002000; {$EXTERNALSYM TAPE_DRIVE_EOT_WZ_SIZE}
  TAPE_DRIVE_ECC             = $00010000; {$EXTERNALSYM TAPE_DRIVE_ECC}
  TAPE_DRIVE_COMPRESSION     = $00020000; {$EXTERNALSYM TAPE_DRIVE_COMPRESSION}
  TAPE_DRIVE_PADDING         = $00040000; {$EXTERNALSYM TAPE_DRIVE_PADDING}
  TAPE_DRIVE_REPORT_SMKS     = $00080000; {$EXTERNALSYM TAPE_DRIVE_REPORT_SMKS}
  TAPE_DRIVE_GET_ABSOLUTE_BLK = $00100000; {$EXTERNALSYM TAPE_DRIVE_GET_ABSOLUTE_BLK}
  TAPE_DRIVE_GET_LOGICAL_BLK = $00200000; {$EXTERNALSYM TAPE_DRIVE_GET_LOGICAL_BLK}
  TAPE_DRIVE_SET_EOT_WZ_SIZE = $00400000; {$EXTERNALSYM TAPE_DRIVE_SET_EOT_WZ_SIZE}
  TAPE_DRIVE_EJECT_MEDIA     = $01000000; {$EXTERNALSYM TAPE_DRIVE_EJECT_MEDIA}
  TAPE_DRIVE_CLEAN_REQUESTS  = $02000000; {$EXTERNALSYM TAPE_DRIVE_CLEAN_REQUESTS}
  TAPE_DRIVE_SET_CMP_BOP_ONLY = $04000000; {$EXTERNALSYM TAPE_DRIVE_SET_CMP_BOP_ONLY}

// Definitions for FeaturesHigh parameter
// ACHTUNG für den direkten Bit-Test gemacht, anders als im Standard definiert
const
  TAPE_DRIVE_LOAD_UNLOAD     = $00000001; {$EXTERNALSYM TAPE_DRIVE_LOAD_UNLOAD}
  TAPE_DRIVE_TENSION         = $00000002; {$EXTERNALSYM TAPE_DRIVE_TENSION}
  TAPE_DRIVE_LOCK_UNLOCK     = $00000004; {$EXTERNALSYM TAPE_DRIVE_LOCK_UNLOCK}
  TAPE_DRIVE_REWIND_IMMEDIATE = $00000008; {$EXTERNALSYM TAPE_DRIVE_REWIND_IMMEDIATE}
  TAPE_DRIVE_SET_BLOCK_SIZE  = $00000010; {$EXTERNALSYM TAPE_DRIVE_SET_BLOCK_SIZE}
  TAPE_DRIVE_LOAD_UNLD_IMMED = $00000020; {$EXTERNALSYM TAPE_DRIVE_LOAD_UNLD_IMMED}
  TAPE_DRIVE_TENSION_IMMED   = $00000040; {$EXTERNALSYM TAPE_DRIVE_TENSION_IMMED}
  TAPE_DRIVE_LOCK_UNLK_IMMED = $00000080; {$EXTERNALSYM TAPE_DRIVE_LOCK_UNLK_IMMED}
  TAPE_DRIVE_SET_ECC         = $00000100; {$EXTERNALSYM TAPE_DRIVE_SET_ECC}
  TAPE_DRIVE_SET_COMPRESSION = $00000200; {$EXTERNALSYM TAPE_DRIVE_SET_COMPRESSION}
  TAPE_DRIVE_SET_PADDING     = $00000400; {$EXTERNALSYM TAPE_DRIVE_SET_PADDING}
  TAPE_DRIVE_SET_REPORT_SMKS = $00000800; {$EXTERNALSYM TAPE_DRIVE_SET_REPORT_SMKS}
  TAPE_DRIVE_ABSOLUTE_BLK    = $00001000; {$EXTERNALSYM TAPE_DRIVE_ABSOLUTE_BLK}
  TAPE_DRIVE_ABS_BLK_IMMED   = $00002000; {$EXTERNALSYM TAPE_DRIVE_ABS_BLK_IMMED}
  TAPE_DRIVE_LOGICAL_BLK     = $00004000; {$EXTERNALSYM TAPE_DRIVE_LOGICAL_BLK}
  TAPE_DRIVE_LOG_BLK_IMMED   = $00008000; {$EXTERNALSYM TAPE_DRIVE_LOG_BLK_IMMED}
  TAPE_DRIVE_END_OF_DATA     = $00010000; {$EXTERNALSYM TAPE_DRIVE_END_OF_DATA}
  TAPE_DRIVE_RELATIVE_BLKS   = $00020000; {$EXTERNALSYM TAPE_DRIVE_RELATIVE_BLKS}
  TAPE_DRIVE_FILEMARKS       = $00040000; {$EXTERNALSYM TAPE_DRIVE_FILEMARKS}
  TAPE_DRIVE_SEQUENTIAL_FMKS = $00080000; {$EXTERNALSYM TAPE_DRIVE_SEQUENTIAL_FMKS}
  TAPE_DRIVE_SETMARKS        = $00100000; {$EXTERNALSYM TAPE_DRIVE_SETMARKS}
  TAPE_DRIVE_SEQUENTIAL_SMKS = $00200000; {$EXTERNALSYM TAPE_DRIVE_SEQUENTIAL_SMKS}
  TAPE_DRIVE_REVERSE_POSITION = $00400000; {$EXTERNALSYM TAPE_DRIVE_REVERSE_POSITION}
  TAPE_DRIVE_SPACE_IMMEDIATE = $00800000; {$EXTERNALSYM TAPE_DRIVE_SPACE_IMMEDIATE}
  TAPE_DRIVE_WRITE_SETMARKS  = $01000000; {$EXTERNALSYM TAPE_DRIVE_WRITE_SETMARKS}
  TAPE_DRIVE_WRITE_FILEMARKS = $02000000; {$EXTERNALSYM TAPE_DRIVE_WRITE_FILEMARKS}
  TAPE_DRIVE_WRITE_SHORT_FMKS = $04000000; {$EXTERNALSYM TAPE_DRIVE_WRITE_SHORT_FMKS}
  TAPE_DRIVE_WRITE_LONG_FMKS = $08000000; {$EXTERNALSYM TAPE_DRIVE_WRITE_LONG_FMKS}
  TAPE_DRIVE_WRITE_MARK_IMMED = $10000000; {$EXTERNALSYM TAPE_DRIVE_WRITE_MARK_IMMED}
  TAPE_DRIVE_FORMAT          = $20000000; {$EXTERNALSYM TAPE_DRIVE_FORMAT}
  TAPE_DRIVE_FORMAT_IMMEDIATE = $40000000; {$EXTERNALSYM TAPE_DRIVE_FORMAT_IMMEDIATE}
... und hier der Code zum Anzeigen:

Delphi-Quellcode:
const
  CFeaturesLow: array [0 .. 30] of string = (
    'Creates `fixed´ data partitions',
    'Creates `select´ data partitions',
    'Creates `initiator-defined´ partitions',
    '',
    'Supports `short erase´ operations',
    'Supports `long erase´ operations',
    'Performs erase operations from the beginning-of-partition marker only',
    'Performs immediate erase operations (returns when the erase operation begins)',
    'Returns the maximum capacity of the tape',
    'Returns the remaining capacity of the tape',
    'Supports `fixed-length´ block mode',
    'Supports `variable-length´ block mode',
    'Returns error if tape is `write-enabled´ or `write-protected´',
    'Supports the `end-of-medium´ warning size',
    '',
    '',
    'Supports hardware error correction',
    'Supports hardware data compression',
    'Supports data padding',
    'Supports setmark reporting',
    'Provides current device-specific block address',
    'Provides current logical block address (and logical tape partition)',
    'Supports setting the `end-of-medium´ warning size',
    '',
    'Physically ejects tape on a software eject',
    'Can report if cleaning is required',
    'Can set compression at the beginning-of-partition marker only',
    '',
    '',
    '',
    ''
  );

  CFeaturesHigh: array [0 .. 30] of string = (
    'Enables and disables the device for further operations',
    'Supports tape tensioning',
    'Enables and disables the tape ejection mechanism',
    'Supports immediate rewind operation',
    'Supports setting the size of a fixed-length logical block or variable-length block mode',
    'Supports immediate load and unload operations',
    'Supports immediate tape tensioning',
    'Supports immediate lock and unlock operations',
    'Enables and disables hardware error correction',
    'Enables and disables hardware data compression',
    'Enables and disables data padding',
    'Enables and disables the reporting of setmarks',
    'Can move to a device specific block address',
    'Can move to a device-specific block address immediately',
    'Can move to a logical block address in a partition',
    'Can move to a logical block address in a partition immediately',
    'Can move to the end-of-data marker in a partition',
    'Can move forward (or backward) a specified number of blocks',
    'Can move forward (or backward) a specified number of filemarks',
    'Can move forward (or backward) to the first occurrence of a specified number of consecutive filemarks',
    'Can move forward (or backward) a specified number of setmarks',
    'Can move forward (or backward) to the first occurrence of a specified number of consecutive setmarks',
    'Can move backward over blocks, filemarks, or setmarks',
    'Supports immediate spacing',
    'Writes setmarks',
    'Writes filemarks',
    'Writes short filemarks',
    'Writes long filemarks',
    'Supports immediate writing of short and long filemarks',
    'Supports tape formatting operations',
    'Supports immediate tape formatting operations'
  );

//...
const
  YesNo: array [boolean] of string[3] = ( 'No', 'Yes' );
  Boxed: array [boolean] of string[3] = ( ' - ', ' X ' );
var
  hf: THandle;
  dp: TTapeGetDriveParameters;
  err, dw: DWORD;
  k: integer;

  procedure Msg(const str: string);
  begin
    Memo1.Lines.Add(str);
  end;

begin
  // ...
    Msg('Querying drive information');

    dw := SizeOf(dp);
    err := GetTapeParameters(hf, GET_TAPE_DRIVE_INFORMATION, dw, @dp);
    if err <> NO_ERROR then
      RaiseLastOsError(err);

    Msg('Drive information:');
    Msg(Format(' ECC: %s', [YesNo[dp.ECC]]));
    Msg(Format(' Compression: %s', [YesNo[dp.Compression]]));
    Msg(Format(' DataPadding: %s', [YesNo[dp.ECC]]));
    Msg(Format(' ReportSetmarks: %s', [YesNo[dp.ReportSetmarks]]));
    Msg(Format(' DefaultBlockSize: %d', [dp.DefaultBlockSize]));
    Msg(Format(' MaximumBlockSize: %d', [dp.MaximumBlockSize]));
    Msg(Format(' MinimumBlockSize: %d', [dp.MinimumBlockSize]));
    Msg(Format(' MaximumPartitionCount: %d', [dp.MaximumPartitionCount]));
    Msg(Format(' FeaturesLow: $%x', [dp.FeaturesLow]));
    for k := 0 to 30 do
      if CFeaturesLow[k] <> '' then
        Msg(Format('   [%s] %s', [Boxed[Odd(dp.FeaturesLow shr k)], CFeaturesLow[k]]));
    Msg(Format(' FeaturesHigh: $%x', [dp.FeaturesHigh]));
    for k := 0 to 30 do
      if CFeaturesHigh[k] <> '' then
        Msg(Format('   [%s] %s', [Boxed[Odd(dp.FeaturesHigh shr k)], CFeaturesHigh[k]]));
    Msg(Format(' EOTWarningZoneSize: %d', [dp.EOTWarningZoneSize]));
  // ...

shifter 11. Nov 2005 16:09

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Also Bei Mir Sieht es so aus :

  • Drive information:
    ECC: No
    Compression: No
    DataPadding: No
    ReportSetmarks: Yes
    DefaultBlockSize: 512
    MaximumBlockSize: 65536
    MinimumBlockSize: 1
    MaximumPartitionCount: 2
    FeaturesLow: $3A1CE1
    [ X ] Creates `fixed´ data partitions
    [ - ] Creates `select´ data partitions
    [ - ] Creates `initiator-defined´ partitions
    [ - ] Supports `short erase´ operations
    [ X ] Supports `long erase´ operations
    [ X ] Performs erase operations from the beginning-of-partition marker only
    [ X ] Performs immediate erase operations (returns when the erase operation begins)
    [ - ] Returns the maximum capacity of the tape
    [ - ] Returns the remaining capacity of the tape
    [ X ] Supports `fixed-length´ block mode
    [ X ] Supports `variable-length´ block mode
    [ X ] Returns error if tape is `write-enabled´ or `write-protected´
    [ - ] Supports the `end-of-medium´ warning size
    [ - ] Supports hardware error correction
    [ X ] Supports hardware data compression
    [ - ] Supports data padding
    [ X ] Supports setmark reporting
    [ X ] Provides current device-specific block address
    [ X ] Provides current logical block address (and logical tape partition)
    [ - ] Supports setting the `end-of-medium´ warning size
    [ - ] Physically ejects tape on a software eject
    [ - ] Can report if cleaning is required
    [ - ] Can set compression at the beginning-of-partition marker only
    FeaturesHigh: $135F527F
    [ X ] Enables and disables the device for further operations
    [ X ] Supports tape tensioning
    [ X ] Enables and disables the tape ejection mechanism
    [ X ] Supports immediate rewind operation
    [ X ] Supports setting the size of a fixed-length logical block or variable-length block mode
    [ X ] Supports immediate load and unload operations
    [ X ] Supports immediate tape tensioning
    [ - ] Supports immediate lock and unlock operations
    [ - ] Enables and disables hardware error correction
    [ X ] Enables and disables hardware data compression
    [ - ] Enables and disables data padding
    [ - ] Enables and disables the reporting of setmarks
    [ X ] Can move to a device specific block address
    [ - ] Can move to a device-specific block address immediately
    [ X ] Can move to a logical block address in a partition
    [ - ] Can move to a logical block address in a partition immediately
    [ X ] Can move to the end-of-data marker in a partition
    [ X ] Can move forward (or backward) a specified number of blocks
    [ X ] Can move forward (or backward) a specified number of filemarks
    [ X ] Can move forward (or backward) to the first occurrence of a specified number of consecutive filemarks
    [ X ] Can move forward (or backward) a specified number of setmarks
    [ - ] Can move forward (or backward) to the first occurrence of a specified number of consecutive setmarks
    [ X ] Can move backward over blocks, filemarks, or setmarks
    [ - ] Supports immediate spacing
    [ X ] Writes setmarks
    [ X ] Writes filemarks
    [ - ] Writes short filemarks
    [ - ] Writes long filemarks
    [ X ] Supports immediate writing of short and long filemarks
    [ - ] Supports tape formatting operations
    [ - ] Supports immediate tape formatting operations
    EOTWarningZoneSize: 0



Nur warum andere Software Kann ShortErase durchführen ???

gruss
seba

shifter 11. Nov 2005 16:51

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Ich habe es noch ein mal anders versucht :
Delphi-Quellcode:
Var buf  : Pointer;
    re   : boolean;
    bow  : dword;
    bor  : dword;
    lcm  : pointer;
    inf  : thandle;
    tot  : dWord;
    tot1  : dWord;
begin

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

  SetTapePosition ( TapeHandle, 4, 0, 0,0, False );

  buf := VirtualAlloc( nil, 512, MEM_COMMIT, PAGE_READWRITE );
  inf := CreateFile('C:\mt.exe',GENERIC_READ,0,
              @Security,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

  tot := 0;
  tot1:= 0;
  bor := 1;
  While bor>0 do Begin
    lcm := nil;
    re := ReadFile(inf,buf,512,bor,lcm);
    If bor>0 Then Begin
      lcm := nil;
      re := WriteFile( TapeHandle, buf, bor, bow, lcm);
      Inc( tot, bor );
      Inc( tot1,bow );
    End;
  End;
  ShowMessage('Read :'+inttostr(tot)+chr(10)+'Write :'+IntToStr(tot1));

  WriteTapeMark( TapeHandle, 0, 1, False );

  CloseHandle( inf );
  CloseDrive;

  VirtualFree( buf, 512, MEM_DECOMMIT );
Es sieht garnicht so schlecht aus.
Es wird auf dem Band aufgenohmen aber ab den Offset 4 jest 512 Bytes gibts differenz zur orginal file. Die differenz ist 8 Byte Lang und wiederholt sich regelmessig jede 512 Bytes.

Und am Ende Bekomme ich noch ein mechtiges Delphi Abstürz. vermutlich geht hier um den speicher ( immer noch )

shifter 11. Nov 2005 18:00

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Der Fehler am Ende, kommt ungefähr nach 2-5 sek und lautet :

bds.exe - bordbk90N.dll
Internal Error IMP-2627

nach par mal ok kommt

Acces violation adress xy in module 'bordbk90N.dll'. Read of adresse xy.

:wall: :wall: :wall: :wall: :wall: :wall: :wall: :wall:

Flocke 11. Nov 2005 19:20

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
1. Microsoft empfiehlt ~100 Blocks am Anfang einer Partition zu überspringen, da manche Streamer dort eigene Daten ablegen, du solltest also jeweils ein
Delphi-Quellcode:
SetTapePosition(TapeHandle, TAPE_LOGICAL_BLOCK, 0, 100, 0, false);
vor das Lesen und Schreiben setzen.

2. Du MUSST bei ReadFile als 5. Parameter nil angeben, ansonsten meint Windows, dass du überlappende I/O-Operationen durchführen willst. Das dürfte deine verzögerten Abstürze verursachen.

3. Du solltest den Speicher mit
Delphi-Quellcode:
VirtualFree(buf, 0, MEM_RELEASE);
wieder freigeben.

shifter 12. Nov 2005 13:18

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Hi, Danke .

Wede sofort in angriff nehmen.

Weist du vieleicht wo kann mann überprüfen den eingelegten band typ ?
Also bei anderen back.prog. zeigt der mir an welchen band tüp ich gerade in laufwerk habe,
zb 50GB oder 24 GB ...

Gruss
seba

shifter 12. Nov 2005 14:23

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Zitat:

Zitat:

Zitat von Flocke
1. Microsoft empfiehlt ~100 Blocks am Anfang einer Partition zu überspringen, da manche Streamer dort eigene Daten ablegen, du solltest also jeweils ein
Delphi-Quellcode:
SetTapePosition(TapeHandle, TAPE_LOGICAL_BLOCK, 0, 100, 0, false);
vor das Lesen und Schreiben setzen.

Wenn das Band ist Gelöscht dann kann ich nicht weiter nach hinten vorspullen wie der letzte verwende Block, in falle direckt nach dem EraseTape ist das Block Nr. 1. Somit wenn ich setpos auf block 100 mache bleibt er bei block nr. 1 stehen.

Zitat:

2. Du MUSST bei ReadFile als 5. Parameter nil angeben, ansonsten meint Windows, dass du überlappende I/O-Operationen durchführen willst. Das dürfte deine verzögerten Abstürze verursachen.

3. Du solltest den Speicher mit
Delphi-Quellcode:
VirtualFree(buf, 0, MEM_RELEASE);
wieder freigeben.

Exackt habe ich so gemacht, Delphi hängt sich auf, bds process muss über taskmanager beendet werden.

schade, mir ist schon schlecht :wall: ;

seba

shifter 14. Nov 2005 02:27

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Hi,

ich glaube ich hab das Problemm gelöst, es funktioniert.

Aber zurück zum den Roport.

Das erste Report von DriveParameters hat angezeigt da das laufwerk nicht unterstützt Compression,
nach dem ich ein bespieltes band mit anderen software eingelegt habe und den test nochmal durchgeführt habe ist folgendes ergebis gekommen :

  • Drive information:
    ECC: No
    Compression: Yes
    DataPadding: No
    ReportSetmarks: Yes
    DefaultBlockSize: 512
    MaximumBlockSize: 65536
    MinimumBlockSize: 1
    MaximumPartitionCount: 2

Siehe Compression.

:gruebel:
seba

joehd 19. Aug 2009 11:43

Re: Bandlaufwerk / Streamer ansprechen unter Delphi.
 
Der Thread ist ja aus 2005 hat zufällig jemand daran weiter geschrieben und eine halbwegs brauchbare Lösung
Wäre schon nett sonst muß ich alles nochmal machen und mich auch mit den Problemen auseinandersetzen :-(

Grüße Joachim


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:00 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz