Autor Beitrag
uNkn0wn_d4_r3aL
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Mo 28.02.05 21:48 
öhm,

ja wie binde ich die TDosCommans-Kompontente genau ein? hab schon rumprobiert usw. kappt aber nicht! muss man da noch irgendwas genau definieren?!

danke für die aufmerksamkeit :D
cya

Moderiert von user profile iconTino: Überflüssige Absätze entfernt.
Moderiert von user profile iconTino: Topic aus Windows API verschoben am Mo 28.02.2005 um 23:40
Dominique
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 92



BeitragVerfasst: Mo 28.02.05 22:09 
uNkn0wn_d4_r3aL hat folgendes geschrieben:
öhm,
ja wie binde ich die TDosCommans-Kompontente genau ein?


was genau möchtest du denn machen?

eine consolenanwendung nur ausführen, ausführen und warten, oder soger die ausgabe der console in einem memo bzw. richedit ausgeben?

im komponenten-source ist doch eine anleitung:

Zitat:

How to use it :
---------------
- just put the line of command in the property 'CommandLine'
- execute the process with the method 'Execute'
- if you want to stop the process before it has ended, use the method 'Stop'
- if you want the process to stop by itself after XXX sec of activity,
use the property 'MaxTimeAfterBeginning'
- if you want the process to stop after XXX sec without an output,
use the property 'MaxTimeAfterLastOutput'
- to directly redirect outputs to a memo or a richedit, ...
use the property 'OutputLines'
(DosCommand1.OutputLnes := Memo1.Lines;)
- you can access all the outputs of the last command with the property 'Lines'
- you can change the priority of the process with the property 'Priority'
value of Priority must be in [HIGH_PRIORITY_CLASS, IDLE_PRIORITY_CLASS,
NORMAL_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS]
- you can have an event for each new line and for the end of the process
with the events 'procedure OnNewLine(Sender: TObject; NewLine: string;
OutputType: TOutputType);' and 'procedure OnTerminated(Sender: TObject);'
- you can send inputs to the dos process with 'SendLine(Value: string;
Eol: Boolean);'. Eol is here to determine if the program have to add a
CR/LF at the end of the string.
*******************************************************************
How to call a dos function (win 9x/Me) :
----------------------------------------

Example : Make a dir :
----------------------
- if you want to get the result of a 'c:\dir /o:gen /l c:\windows\*.txt'
for example, you need to make a batch file
--the batch file : c:\mydir.bat
@echo off
dir /o:gen /l %1
rem eof
--in your code
DosCommand.CommandLine := 'c:\mydir.bat c:\windows\*.txt';
DosCommand.Execute;

Example : Format a disk (win 9x/Me) :
-------------------------
--a batch file : c:\myformat.bat
@echo off
format %1
rem eof
--in your code
var diskname: string;
--
DosCommand1.CommandLine := 'c:\myformat.bat a:';
DosCommand1.Execute; //launch format process
DosCommand1.SendLine('', True); //equivalent to press enter key
DiskName := 'test';
DosCommand1.SendLine(DiskName, True); //enter the name of the volume


oder hast du schon schwierigkeiten, die komponente überhaupt zu installieren?
uNkn0wn_d4_r3aL Threadstarter
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Mo 28.02.05 22:33 
Zitat:
DosCommand.CommandLine := 'c:\mydir.bat c:\windows\*.txt';
DosCommand.Execute;


wenn ich das in die unit1.pas kopier, z.b. so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
DosCommand.CommandLine := 'c:\mydir.bat c:\windows\*.txt'
DosCommand.Execute;
end;


=> fehler:
Undefinierter Bezeichner "CommandLine"

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.
Dominique
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 92



BeitragVerfasst: Mo 28.02.05 22:57 
uNkn0wn_d4_r3aL hat folgendes geschrieben:

=> fehler:
Undefinierter Bezeichner "CommandLine"


hier ein ausschnitt aus dem source :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
  TDosCommand = class(TComponent) //the component to put on a form
  private

  ...

  published
    property CommandLine: string read FCommandLine write FCommandLine;
      //command to execute

  ...

  end;



Wir sprechen von der gleichen Komponente?
von DIESEM Author: maxxdelphisite.free.fr/doscmd.htm ???
uNkn0wn_d4_r3aL Threadstarter
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Mo 28.02.05 23:04 
ja, wir prechen vom selben!
wie muss ich die kompontene genau in mein programm einbinden?
vielleicht ist da der fehler.


Zuletzt bearbeitet von uNkn0wn_d4_r3aL am Mo 28.02.05 23:44, insgesamt 2-mal bearbeitet
Dominique
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 92



BeitragVerfasst: Mo 28.02.05 23:13 
uNkn0wn_d4_r3aL hat folgendes geschrieben:

wie muss ich die kompontene genau in mein programm einbinden?


im Menü auf Komponente -> Komponete Installieren

Name der Unit : c:\...\doscommand.pas

Suchpfad: [hier ggf. den Pfad zur Komponente zufügen - ich mache das lieber in den Projektoptionen]

Name des Packages: c:\....\dclusr.dpk [standard "borland anwenderkomponenten" kannst'e so lassen]

auf OK klicken, dann kommt die frage "package dclusr.bpl wird neu compiliert..."
mit Ja bestätigen,

fertig

vieleicht kommt die frage, ob änderungen in der dclusr.dpk gespeichert werden sollen, mit Ja bestätigen.

dann eine neue anwendung, die Komponente von der Registerkarte "Samples" auf's Formular ziehen
und ab geht's :)
Dominique
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 92



BeitragVerfasst: Mo 28.02.05 23:20 
uNkn0wn_d4_r3aL hat folgendes geschrieben:
ja, wir prechen vom selben!
wie muss ich die kompontene genau in mein programm einbinden?
vielleicht ist da der fehler.


soll ich dir ein demo-programm zuschicken???
uNkn0wn_d4_r3aL Threadstarter
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Di 01.03.05 00:11 
jo, ab gehts :D
vielen dank für deine hilfe!
hatte die komponente falsch "installiert" bzw. gar nicht :P
Minime
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mo 24.07.06 12:18 
giebt es auch eine möglichkeit das ohne die form zu nutzen also mittels create initialisieren bei kommt da aber immer ein fehler