Autor Beitrag
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Fr 21.12.07 18:45 
Ich öffne einen DAtei mit einem FileStream...
Funktioniert...
Dann will ich ein einziges Zeichen daraus lesen, Access Violation...
ausblenden Delphi-Quelltext
1:
2:
3:
myStream := TFileStream.Create('C:\streamdatei.txt', fmOpenRead);
myStream.Read(buffer, 1);
myStream.Free;


Wieso funktioniert das nicht?

_________________
1405006117752879898543142606244511569936384000000000.
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: Fr 21.12.07 18:53 
Was hat Buffer für einen Dateityp?
(So wie du es machst sollte es vom Typ Byte sein)

Chris
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 21.12.07 18:55 
Was ist denn Buffer für ein Typ? Wenns n dynamisches Array ist (was ich einfach mal vermute), dann geht das so:

ausblenden Delphi-Quelltext
1:
2:
Setlength(buffer,1);
myStream.Read(buffer[0], 1);


besser wäre aber z.B. sowas, falls es um kleine Dateien geht:

ausblenden Delphi-Quelltext
1:
2:
Setlength(buffer,{ Dateigröße });
myStream.Read(buffer[0], { Dateigröße } );

_________________
We are, we were and will not be.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Fr 21.12.07 18:57 
buffer ist ein String...
und ich will auch nur ein einziges Zeichen lesen, also ist 1 schon richtig...

_________________
1405006117752879898543142606244511569936384000000000.
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: Fr 21.12.07 18:58 
Dann solltest du BYTE nehmen und mit chr() in einen Char umwandeln...

Chris
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 21.12.07 18:59 
Wenn buffer ein String ist, dann isses quasi ein dynamisches Array. Erst die Länge setzen, und dann den Inhalt beginnend bei buffer[1] einlesen.

_________________
We are, we were and will not be.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Fr 21.12.07 19:23 
Danke, aber beim Gewinnspiel kommt trotzdem nichts gescheites raus...

_________________
1405006117752879898543142606244511569936384000000000.
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: Fr 21.12.07 19:25 
Bei dir ;)
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Fr 21.12.07 19:31 
Ja... *Noch nen tipp will*

_________________
1405006117752879898543142606244511569936384000000000.
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: Fr 21.12.07 19:37 
[OT]Also, es ist so dermaßen einfach, dass noch mehr Tipps einfach übertrieben wären (meiner Meinung nach) :P[/OT]
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Fr 21.12.07 19:49 
:bawling: :bawling: :bawling: :bawling: :bawling: :bawling:
Männo... Was anderes fällt mir aber nicht ein, als das, was ich schon versucht habe...

_________________
1405006117752879898543142606244511569936384000000000.