Autor Beitrag
Hack Gott
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Mo 14.02.05 17:10 
Ich habe einen String und wollte diesen gerne (für shellexecute) in einen PAnsiChar umwandeln, geht das irgendwie?
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 14.02.05 17:14 
Typecasting lautet das Zauberwort.

AXMD
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 14.02.05 17:15 
geht das nicht do?

ausblenden Delphi-Quelltext
1:
PChar('Hallo')					
ScorpionKing
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1150

Win XP

BeitragVerfasst: Mo 14.02.05 17:16 
stimmt, aber ich glaube es gibt noch eine schwere methode! :D
nein, das ist schon richtig, aber code dir mal eine special-shellexecute, damit du nciht immer typcast machen musst!

_________________
Aus dem Urlaub zurück!
Hack Gott Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Mo 14.02.05 17:28 
OneOfTen hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
PChar('Hallo')					


Das hat bei mir nicht geklappt, da wird immer noch angezeigt dass PAnsiChar und String inkompatible Typen sind. Und das mit dm Typecasting hab ich net ganz kapiert, wie soll ich das jetzt ver wenden mit () hat´s net geklappt und mit := auch net.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 14.02.05 17:31 
Hack Gott hat folgendes geschrieben:
OneOfTen hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
PChar('Hallo')					


Das hat bei mir nicht geklappt, da wird immer noch angezeigt dass PAnsiChar und String inkompatible Typen sind. Und das mit dm Typecasting hab ich net ganz kapiert, wie soll ich das jetzt ver wenden mit () hat´s net geklappt und mit := auch net.


Das glaub ich dir irgendwie nicht... folgender Code

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.FormCreate(Sender: TObject);
var
  bla: String;
  blub: PAnsiChar;
begin
  blub := PAnsiChar(bla);
end;


lässt sich nämlich ohne Probleme kompilieren... Und wenn man folgenden Code ausführt...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.FormCreate(Sender: TObject);
var
  bla: String;
  blub: PAnsiChar;
begin
  bla := 'Hello world :)!';
  blub := PAnsiChar(bla);
  bla := StrPas(blub);
  ShowMessage(bla);
end;


erhält man ein Hello world-Fenster :roll:

AXMD
Hack Gott Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Mo 14.02.05 17:33 
Titel: Klappt immer noch net
Die Fehlermeldung kommt ja auch nur bei Shellexecute
ScorpionKing
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1150

Win XP

BeitragVerfasst: Mo 14.02.05 17:34 
wenn bei dir

ausblenden Quelltext
1:
Pchar('Hallo');					


keinen pchar liefert, dann frag ich mich, was für eine delphi-version du hast?! :lol:
ich glaub, dass wäre dann noch nicht mal delphi! :wink:

_________________
Aus dem Urlaub zurück!
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 14.02.05 17:35 
Titel: Re: Klappt immer noch net
Hack Gott hat folgendes geschrieben:
Die Fehlermeldung kommt ja auch nur bei Shellexecute


Wie wärs wenn du mal Code posten würdest :roll:

AXMD
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Mo 14.02.05 17:42 
Titel: Re: Klappt immer noch net
Hack Gott hat folgendes geschrieben:
Die Fehlermeldung kommt ja auch nur bei Shellexecute
Wie wärs wenn du uns den entsprechenden Ausschnitt aus deinem Quelltext zeigst?

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 14.02.05 17:45 
Wenn der Threadsteller innerhalb von 7 min nicht antwortet, einfach den letzten Beitrag umformulieren, gute Idee wulfskin :wink:
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 14.02.05 17:48 
@TopOfTen: bitte beim Thema bleiben :mahn:

Danke :)
AXMD
ScorpionKing
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1150

Win XP

BeitragVerfasst: Mo 14.02.05 17:49 
OneOfTen hat folgendes geschrieben:
Wenn der Threadsteller innerhalb von 7 min nicht antwortet, einfach den letzten Beitrag umformulieren, gute Idee wulfskin :wink:


oder sinnlose antworten schreiben, he?

hier mal ein winexec der klappt (winexec ist einfacher und klappt genauso):

ausblenden Delphi-Quelltext
1:
WinExec(pchar('notepad.exe'),SW_NORMAL);					



MfG, scorpion!

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.

_________________
Aus dem Urlaub zurück!
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 14.02.05 17:51 
ScorpionKing hat folgendes geschrieben:
hier mal ein winexec der klappt (winexec ist einfacher und klappt genauso):


Es sollte trotzdem nicht mehr verwendet werden. Außerdem geht's mit ShellExecute ja auch :)

AXMD
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 14.02.05 17:53 
WinExec sollte man aufgrund der Kompatibilität nicht mehr benutzen, hab ich schon, was weiß ich, wie oft, gelesen.


auch mal zu langsam...
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Mo 14.02.05 17:56 
Zitat:
Note This function is provided only for compatibility with 16-bit Windows
Benutz lieber ShellExecute:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  FileName, Parameters, Directory: String;
begin
  ShellExecute(Handle, 'open', PChar(FileName), PChar(Parameters), PChar(Directory), SW_SHOW);


Gruß Hape!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
DelphiFreund
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 120

Win XP
D7 Enterprise
BeitragVerfasst: Mo 14.02.05 18:33 
Ich hatte dieses Problem auchmal, das ShellExexute trotz PChar nicht funktionieren wollte, es funktioniert auch immer noch nicht, ich hab dann eine bat Datei geschrieben und die ausgeführt :duck:

_________________
Irren ist menschlich...
Hack Gott Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Do 17.02.05 15:52 
DelphiFreund hat folgendes geschrieben:
Ich hatte dieses Problem auchmal, das ShellExexute trotz PChar nicht funktionieren wollte, es funktioniert auch immer noch nicht, ich hab dann eine bat Datei geschrieben und die ausgeführt :duck:

Komfortabel, komfortabel!

zu Winexec, da kann man keine paramenter übergeben.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Do 17.02.05 15:57 
Boah. So ein Quatsch. Poste jetzt doch einfach mal den Code!!!

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
Hack Gott Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Do 17.02.05 16:03 
Titel: Danke
wulfskin hat folgendes geschrieben:
Zitat:
Note This function is provided only for compatibility with 16-bit Windows
Benutz lieber ShellExecute:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  FileName, Parameters, Directory: String;
begin
  ShellExecute(Handle, 'open', PChar(FileName), PChar(Parameters), PChar(Directory), SW_SHOW);


Gruß Hape!


Jetzt klappt alles!