Autor Beitrag
futti
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

WIN 2000
D3 Prof, Delphi 2005 Prof
BeitragVerfasst: Mi 31.05.06 13:01 
Hallo Leute,

ich habe ein Problem. Ich bin gerade dabei Code aus Delphi Win32 nach Delphi .NET zu portieren.
Im Moment habe ich gerade das Problem, dass eine Funktion einen Parameter als pwidechar erwartet. Ich habe einen String, den ich übergeben möchte.
Ich erhalte folgende Fehlermeldung:
E2010 Inkompatible Typen: 'pwidechar' und 'string'
Ich habe schon verschiedenste Castings ausprobiert und im Netz gesucht aber leider nichts gefunden, was sich verwerten lässt. Die Fehlermeldung bei den Castings lautet:
E2089 Ungültige Typumwandlung

Hat jemand schon ein ähnliches Probelm gehabt und kann mir helfen?

Vielen Dank,
Futtti
Arno Nym
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Mi 31.05.06 13:11 
Hi!
da musst du den Umweg über einen Widestring machen...folgendes z.B. funktioniert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var x : String;
    y : Widestring;
    z : Pwidechar;
begin
 x := 'Hallo';
 y := x;
 z := Pwidechar(y);
 Showmessage(z);
end;


MFG, Arno Nym

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
futti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

WIN 2000
D3 Prof, Delphi 2005 Prof
BeitragVerfasst: Mi 31.05.06 13:36 
Hallo Arno,

ich den Code von dir getestet.
Ich bekomme in der Zeile:

z := Pwidechar(y);
wieder die Meldung: ungültige Typumwandlung.

Muss ich noch etwas beachten?

Danke Futti
Arno Nym
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Mi 31.05.06 13:47 
Hi!
Ok, dann liegts wohl an unseren unterschiedlichen Delphi-Versionen.
Hast du mal die Funktion "StringToOleStr" ausprobiert ?
MFG, Arno Nym
futti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

WIN 2000
D3 Prof, Delphi 2005 Prof
BeitragVerfasst: Do 01.06.06 09:15 
Habe jetzt erstmal die Adresse des Strings an ein pchar übergeben. Das kann man wenigstens compilieren. Getestet habe ich es noch nicht, da schon wieder ein anderer fehler aufgetreten ist.