Autor Beitrag
Uli Schoch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 03.05.08 17:21 
Hallo zusammen
Ich will per Delphi 3 ganz banal ein Text-File kopieren. Das geht im Prinzi mit CopyFile(src,dst,false). src und dst müssen aber nullterminierte Strings sein. Bei mir sind das aber normale Delphistrings, z.B. DLB.Directory+'\Temp.txt'. Wie muss ich diese in PChar umwandeln? Irgendwie habe ich im Hinterkopf die Meinung, Delphi hätte eine Kopierprocedure mit ganz normalen Delphistrings als Parameter.

Wer weiss das genau?

Gruss
Uli
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 03.05.08 17:30 
Setz um deine String-Parameter einfach ein PChar( ) drumrum. Dann gehts. ;-)

_________________
We are, we were and will not be.
Uli Schoch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 03.05.08 18:17 
Das geht leider nicht. Ich habe folgenden Code geschrieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  src, dst ; string;

...

CopyFile(src,dst,false);


Dann kommt beim cCompilieren die Fehlermeldung "Ungültige Typumwandlung", 2 mal, wegen src und dst.
Was ist da falsch?

Gruss
Uli
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Sa 03.05.08 18:24 
user profile iconUli Schoch hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  src, dst ; string;

...

CopyFile(src,dst,false);


Dann kommt beim cCompilieren die Fehlermeldung "Ungültige Typumwandlung", 2 mal, wegen src und dst.
Was ist da falsch?


erst lesen, dann denken, dann erst schreiben bitte! :mahn:

so muss es aussehen und so hats auch gausi gemeint:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  src, dst ; string;

...

CopyFile(PChar(src),PChar(dst),false);


lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
Uli Schoch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 03.05.08 20:40 
Hallo


So "CopyFile(PChar(src),PChar(dst),false); " hab ichs auch geschrieben im Quellcode, beim Postingschreiben habe ich geschlafen, äxgüsi. Aber da kommt dann eben beim Compilieren die Fehlermeldung "Ungültige Typumwandlung", 2 mal, wegen src und dst.
Was ist da falsch?

Gruss
Uli
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 03.05.08 20:42 
ausblenden Delphi-Quelltext
1:
2:
var 
  src, dst ; string;


ist ein Copy&Paste Fehler, oder? Im Originalcode steht
ausblenden Delphi-Quelltext
1:
2:
var 
  src, dst : string;


Oder?

_________________
We are, we were and will not be.
Uli Schoch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 03.05.08 21:16 
Hallo nochmals
Ja, der ";" ist natürlich falsch im Posting, im Code steht korrekt ":". Die Fehlermeldung kommt auch erst beim Copyfile. Ich habe noch festgestellt, dass es geht, wenn ich in den Projektoptionen "Huge-Strings" einschalte. Es müsste aber auch ohne gehen, aber wie?

Gruss
Uli