Autor Beitrag
JWI
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 08.03.05 16:50 
Hallo zusammen,

wie nun einem Delphi Programm der Parameter übergeben wird, habe ich soeben gelesen.
Mein Problem ist, wo und wie wird im ( aufgerufenen ) Delphi Programm der Parameter zugeordnet ?


Moderiert von user profile iconGausi: Topic aus Windows API verschoben am Sa 12.03.2005 um 11:51
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: Di 08.03.05 16:52 
Also wenn du die Variable meinst, wo dann der Parameter drinsteht, das ist ParamStr(x). ;)

Achtung: ParamStr(0) ist der Pfad der Exe + deren Dateiname.
JWI Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 08.03.05 17:02 
Bin vielleicht ein wenig dumm !

Meine Frage zielt darauf wie ich im Delphi Quellcode die Verbindung zum Parameter herstellen kann.
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: Di 08.03.05 17:08 
Klingt immer noch so, als ob du einfach die Variable (ok, vielleicht falsche Bezeichnung) oder einfach das Ding (ah, Funktion), das dir den x-ten Parameter zurückgibt.

Schreibst du (Annahme: Project1.exe ist dein Programm):
ausblenden Quelltext
1:
Project1.exe -config					

Dann ist "-config" der erste Parameter und du kannst ihn im Programm mit ParamStr(1) abfragen. Also z.B.:
ausblenden Delphi-Quelltext
1:
Label1.Caption := ParamStr(1);					

;) Was das so in die Richtung??
JWI Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 08.03.05 17:20 
Habe ich soweit verstanden, der Quellcode sieht nun so aus :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 1 to ParamCount do
  begin
    ShowMessage(paramstr(i));
  end;


Wie kann ich den dem Programm mehr als einen Parameter übergeben ?
project1.exe "Hallo","Test" zeigt das Delphi dann
Hallo, Test
an.
Werden die einzelnen Parameter nicht durch Komma (,) getrennt ?

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 08.03.05 17:29 
nein mit leerzeichen (oder haben die + bzw - eine bedeutung ?)

ausblenden Quelltext
1:
test.exe -start -msgshow -exit					
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Di 08.03.05 17:42 
Hey da kann gleich mit einhaken, weil ich habs problem, dass wenn ich einen Dateityp mit meinem Programm verlinke gibts anschließen nur Salat. Ich öffne z.B. Die Datei "C:\Eigene Dateien\Gibts net.xyz", dann wird halt jeder durch ein Leerzeichen getrennte Teil als neuer ParamStr verpackt (Ergenbis: Teil1: "C:\Eigene", Teil2: "Dateien\Gibts", Teil3: "Net.xyz"). Ich könnte hier auch aufwendige Routinen schreiben :lol: , die mir die Schnipsel wieder zusammensetzen, aber gibts da nix bequemeres? :?:

_________________
Programmers never die, they just GOSUB without RETURN
JWI Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 08.03.05 17:44 
Leerzeichen waren die Lösung.
Das "," sollte nur zur Trennung der einzelnen Parameter dienen.
Irgenwelche Vorzeichen wie "-" oder "+" sollten nicht vorkommen.

Muss ich was beachten, wenn ich von Unix aus dann das Delphi Programm mit Parameterübergabe
starten möchte ?

Vielen Dank
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Di 08.03.05 17:44 
Naja, also die vielen Tippfehler rühren von meiner 10-jahre alten Französischen Tastatur her... :wink: :!:
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 08.03.05 17:45 
stimmt, das is ein problem, wenn sich zb das verzeichnis einer datei ändert, dann
kriegt man den falschen parameter mhhh kA
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Di 08.03.05 18:00 
user profile iconalias5000 hat folgendes geschrieben:
[...]dann wird halt jeder durch ein Leerzeichen getrennte Teil als neuer ParamStr verpackt[...]aber gibts da nix bequemeres? :?:

Setze den Parameter in Anführungszeichen, dann sind die Leerzeichen Bestandteil des Parameters und trennen ihn nicht.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 08.03.05 19:38 
er meint aber glaube ich, dass die addresse als parameter erkannt wird ?!
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Di 08.03.05 19:46 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
er meint aber glaube ich, dass die addresse als parameter erkannt wird ?!

Welche Adresse? M.E. hat er (alias5000) eindeutig das Problem, dass Leerzeichen im Pfad als Parameter-Trennzeichen angesehen werden, wenn man den Pfad nicht in Anführungsstriche setzt.
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Do 10.03.05 18:23 
Also mein Problem ist, dass wenn ich einen Dateityp in Windows ganz normal mit meinem Programm verlinke gibts den Salat. Was passiert, wenn ich eine Datei aus Delphi heraus (Run-->Parameters) in Anführungszeichen verknüpfe weiß ich grade net, werds aber noch probieren THX!!!