Autor Beitrag
STF1982
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Di 26.12.06 18:57 
Hallo,
versuche einfach nur ein externes Programm mit

ausblenden Delphi-Quelltext
1:
ShellExecute(handle,PChar('open'),PChar('notepad.exe'),PChar('C:\Windows\win.ini'),PChar('C:\Windows'),SW_SHOW);					


zu startet, die ShellAPI ist eingebunden - folgede Fehlermeldung erscheint:

E2089 - Ungültige Typumwandlung

Hat jemand Vorschläge??? Besten Dank und Frohe Weihnachten.

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
Michael Stenzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 133


D3 Prof, D7 PE
BeitragVerfasst: Di 26.12.06 19:50 
Hi STF1982!

Ich habe deinen Befehl kopiert und direkt probiert. Es hat bei mir ohne Änderung funktioniert. Vieleicht liegt es an der Procedur wo Du die Funktion aufrufst. Wenn Du z.B. die Variable Handle in deiner Procedur mal so einsetzen würdes:

ausblenden Delphi-Quelltext
1:
 ShellExecute(Form1.handle,PChar('open'),PChar('notepad.exe'),PChar('C:\Windows\win.ini'),PChar('C:\Windows'),SW_SHOW);					


Wobei Du deinen Formularnamen verwenden mußt.

Gruß
Michael
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 26.12.06 20:22 
Erstmal :welcome: hier im Forum!

Die ganzen PChar( brauchst du gar nicht, wenn du nur einen direkt eingegebenen String hinschreibst (also direkt in Anführungszeichen), das brauchst du nur, wenn du da Variablen nutzen willst.

Aber poste doch bitte mal deine ganze Prozedur, nicht nur die eine Zeile!
DelphiNoobCoder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 98

Win XP SP1

BeitragVerfasst: Di 26.12.06 20:23 
Oder vielleicht hast du die Uses vergessen wenn ja
ShellApi
Sry wenns falsch is
Sorry steht schon da
Raffo
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 300



BeitragVerfasst: Di 26.12.06 20:37 
Versuch doch mal, ob diese .exe hier geht

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, shellapi,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(handle,PChar('open'),PChar('notepad.exe'),PChar('C:\Windows\win.ini'),PChar('C:\Windows'),SW_SHOW);
end;

end.
Einloggen, um Attachments anzusehen!
DragonHeart25
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mi 27.12.06 02:21 
also wenn ich den von dir angegebenen quellcode benutze und in delpie einfüge, kommt diese fehlermeldung:

[Fehler] Unit1.pas(33): '.' erwartet, aber Dateiende gefunden
[Fataler Fehler] Project1.dpr(5): Verwendete Unit 'Unit1.pas' kann nicht compiliert werden

könnte mir bitte jemand helfen?

achja nochwas

wie kann man den quelltext als extra fenster einblenden (im forum)?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.12.06 02:24 
Der ist aber korrekt, poste doch bitte mal den kompletten Inhalt deiner Unit so wie du ihn jetzt hast.

// EDIT:
Was die Quelltextdarstellung angeht:
Hier steht wie das geht:
www.delphi-forum.de/...ml&sub=,19,27,32
Die musst du natürlich nicht selbst tippen, du musst nur über dem Eingabefeld auf Bereiche und in diesem Fall dann auf das Plus hinter Delphi einmal vor und einmal nach dem Code schreiben klicken. Mehr dazu hier:
www.delphi-forum.de/...ml&sub=,19,27,32

Ach so: Und wenn du die Fehlerzeilen angibst, dann kannst du die Zitat-Tags (Quote) verwenden.
DragonHeart25
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mi 27.12.06 02:27 
welche unit?

sry bin neu
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.12.06 02:29 
Einfach den kompletten Inhalt des Quelltextfensters.
Solch ein Teil des Projektes nennt sich Unit. Zu jedem Formular gehört solch eine Unit, aber es gibt auch einzelne Units, die Quelltext ohne Formular enthalten.
DragonHeart25
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mi 27.12.06 02:35 
also mein kompletter quelltext lautet:


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, shellapi,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(handle,PChar('open'),PChar('notepad.exe'),PChar('C:\Windows\win.ini'),PChar('C:\Windows'),SW_SHOW);
end;

end


mein fehler:
ausblenden Delphi-Quelltext
1:
2:
[Fehler] Unit1.pas(33): '.' erwartet, aber Dateiende gefunden
[Fataler Fehler] Project1.dpr(5): Verwendete Unit 'Unit1.pas' kann nicht compiliert werden


und ich habe noch einen button eingefügt (graphische ebene)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.12.06 02:37 
:lol: Vergleich mal deinen Quelltext mit dem von user profile iconRaffo...
Du hast den Punkt in der letzten Zeile am Ende nicht mitkopiert...
DragonHeart25
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mi 27.12.06 02:40 
das is mir jetzt schon ein bischen peinlich ^^

ok ich kanns zwar starten aber wenn ich auf den button klick, passiert nix
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.12.06 02:42 
Ja, klick mal im Formulardesigner doppelt drauf. Sonst wird nämlich die Ereignisbehandlungsroutine (der Klick ist ein Ereignis, auf das du mit Button1Click reagieren willst) nicht dem OnClick des Buttons zugeordnet.
DragonHeart25
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mi 27.12.06 02:43 
ja es geht!!
vielen dank
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.12.06 02:45 
Ich empfehle dir mal diesen Crashkurs...
www.christian-stelzm...rtikel/crashkurs.htm
Der ist wirklich gut! Und der fängt wirklich gaaanz am Anfang an.
DragonHeart25
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mi 27.12.06 05:46 
ich will in diesr zeile:

ausblenden Delphi-Quelltext
1:
ShellExecute(handle,PChar('open'),PChar('notepad.exe'),PChar('C:\Windows\win.ini'),PChar('C:\Windows'),SW_SHOW);					


den pfad der datei als variable benutzen. doch wenn ich eine variale reinschreibe, dann sucht er nicht nach dem verzeichniss sondern nach der variablen.

kann ich festlegen, dass der pc die variable übernimmt?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.12.06 05:47 
Ich seh keine Variable? :gruebel:
DragonHeart25
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mi 27.12.06 05:52 
hat sich erledigt^^
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 27.12.06 07:50 
An was lag es?

_________________
Markus Kinzler.