| Autor |
Beitrag |
xxlolxx
      
Beiträge: 48
win xp home
Delphi 7 personal
|
Verfasst: Mi 04.04.07 20:01
Hallo
Wie kann ich mein Programm etwas in die ms-dos konsole schreiben lassen???
|
|
Timosch
      
Beiträge: 1314
Debian Squeeze, Win 7 Prof.
D7 Pers
|
Verfasst: Mi 04.04.07 20:30
Indem du es als Konsolenanwendung kompilierst (unter den Projektoptionen->Linker) und dann mit writeln() oder write() schreiben und mit readln bzw. read() lesen. Übrigens: Verwechsel bitte nicht Eingabeaufforderung mit DOS. DOS hatte eine Eingabeaufforderung, aber das heißt nicht, dass jede Eingabeaufforderung gleich DOS sein muss. Es gibt unter Windows z.B. auch Konsolenprogramme, die aber keine (!) DOS-Programme sind, z.B. der Delphi-Compiler dcc32.exe. Die cmd.exe von Windows ist eine 32-bit-Windows-Anwendung, und kein DOS-Programm. Aber das nur am Rande, um einem Irrtum vorzubeugen. Viele denken nämlich, mit Delphi geschriebene Konsolenanwendungen wären DOS-Programme.
_________________ If liberty means anything at all, it means the right to tell people what they do not want to hear. - George Orwell
Zuletzt bearbeitet von Timosch am Mi 04.04.07 20:49, insgesamt 1-mal bearbeitet
|
|
hansa
      
Beiträge: 3079
Erhaltene Danke: 9
|
Verfasst: Mi 04.04.07 20:49
Timosch, das wird kaum was nützen. Was soll eine Konsolenanwendung anders machen, als ein "DOS-Programm" ? Richtig, man kann eine Datei mit writeln bestücken. Und dann ?
_________________ Gruß
Hansa
|
|
JayEff
      
Beiträge: 2971
Windows Vista Ultimate
D7 Enterprise
|
Verfasst: Mi 04.04.07 23:07
Ich denke, er meint etwas, wie Batch-Code ausführen...  Dazu müsstest du per SaveToFile eine .bat Datei erzeugen und diese mit ShellExecute aufrufen ... oder ... war das der Fall, bei dem man kein Shellexecute benutzen kann? 
_________________ >+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
|
|
hansa
      
Beiträge: 3079
Erhaltene Danke: 9
|
Verfasst: Mi 04.04.07 23:19
Doch Jay, so geht das.
_________________ Gruß
Hansa
|
|
Timosch
      
Beiträge: 1314
Debian Squeeze, Win 7 Prof.
D7 Pers
|
Verfasst: Do 05.04.07 09:33
hansa hat folgendes geschrieben: | | Timosch, das wird kaum was nützen. Was soll eine Konsolenanwendung anders machen, als ein "DOS-Programm" ? Richtig, man kann eine Datei mit writeln bestücken. Und dann ? |
Gut, war schon spät gestern abend. Ich hab gedacht, er will nur etwas in die Konsole schreiben.
Und der Kommentar zu DOS- und Konsolenprogrammen ist nur deswegen erfolgt, weil hier immer noch sehr viele Leute gleuben, das wäre das gleiche.
_________________ If liberty means anything at all, it means the right to tell people what they do not want to hear. - George Orwell
|
|
hansa
      
Beiträge: 3079
Erhaltene Danke: 9
|
Verfasst: Fr 06.04.07 02:38
Timosch hat folgendes geschrieben: | | ..Ich hab gedacht, er will nur etwas in die Konsole schreiben...weil hier immer noch sehr viele Leute gleuben, das wäre das gleiche. |
... und deshalb der Kommentar dazu. 
_________________ Gruß
Hansa
|
|
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Fr 06.04.07 06:17
Es wäre sinnvoll, wenn xxlolxx sich mal konkret dazu äussern würde, was er eigentlich will. cmd.exe kann man genauso von DELPHI aus starten, wie andere Programme auch. ...und hier sind Infos zu cmd.exe: Starts a new instance of the Windows XP command interpreter: | Zitat: | CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF] [[/S] [/C | /K] string]
/C Carries out the command specified by string and then terminates /K Carries out the command specified by string but remains /S Modifies the treatment of string after /C or /K (see below) /Q Turns echo off /D Disable execution of AutoRun commands from registry (see below) /A Causes the output of internal commands to a pipe or file to be ANSI /U Causes the output of internal commands to a pipe or file to be Unicode /T:fg Sets the foreground/background colors (see COLOR /? for more info) /E:ON Enable command extensions (see below) /E:OFF Disable command extensions (see below) /F:ON Enable file and directory name completion characters (see below) /F:OFF Disable file and directory name completion characters (see below) /V:ON Enable delayed environment variable expansion using ! as the delimiter. For example, /V:ON would allow !var! to expand the variable var at execution time. The var syntax expands variables at input time, which is quite a different thing when inside of a FOR loop. /V:OFF Disable delayed environment expansion.
Note that multiple commands separated by the command separator '&&' are accepted for string if surrounded by quotes. Also, for compatibility reasons, /X is the same as /E:ON, /Y is the same as /E:OFF and /R is the same as /C. Any other switches are ignored.
If /C or /K is specified, then the remainder of the command line after the switch is processed as a command line, where the following logic is used to process quote (") characters:
1. If all of the following conditions are met, then quote characters on the command line are preserved:
- no /S switch - exactly two quote characters - no special characters between the two quote characters, where special is one of: &<>()@^| - there are one or more whitespace characters between the the two quote characters - the string between the two quote characters is the name of an executable file.
2. Otherwise, old behavior is to see if the first character is a quote character and if so, strip the leading character and remove the last quote character on the command line, preserving any text after the last quote character.
If /D was NOT specified on the command line, then when CMD.EXE starts, it looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if either or both are present, they are executed first.
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
Command Extensions are enabled by default. You may also disable extensions for a particular invocation by using the /E:OFF switch. You can enable or disable extensions for all invocations of CMD.EXE on a machine and/or user logon session by setting either or both of the following REG_DWORD values in the registry using REGEDT32.EXE:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions
to either 0x1 or 0x0. The user specific setting takes precedence over the machine setting. The command line switches take precedence over the registry settings.
The command extensions involve changes and/or additions to the following commands:
DEL or ERASE COLOR CD or CHDIR MD or MKDIR PROMPT PUSHD POPD SET SETLOCAL ENDLOCAL IF FOR CALL SHIFT GOTO START (also includes changes to external command invocation) ASSOC FTYPE
To get specific details, type commandname /? to view the specifics.
Delayed environment variable expansion is NOT enabled by default. You can enable or disable delayed environment variable expansion for a particular invocation of CMD.EXE with the /V:ON or /V:OFF switch. You can enable or disable completion for all invocations of CMD.EXE on a machine and/or user logon session by setting either or both of the following REG_DWORD values in the registry using REGEDT32.EXE:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion
to either 0x1 or 0x0. The user specific setting takes precedence over the machine setting. The command line switches take precedence over the registry settings.
If delayed environment variable expansion is enabled, then the exclamation character can be used to substitute the value of an environment variable at execution time.
File and Directory name completion is NOT enabled by default. You can enable or disable file name completion for a particular invocation of CMD.EXE with the /F:ON or /F:OFF switch. You can enable or disable completion for all invocations of CMD.EXE on a machine and/or user logon session by setting either or both of the following REG_DWORD values in the registry using REGEDT32.EXE:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar
with the hex value of a control character to use for a particular function (e.g. 0x4 is Ctrl-D and 0x6 is Ctrl-F). The user specific settings take precedence over the machine settings. The command line switches take precedence over the registry settings.
If completion is enabled with the /F:ON switch, the two control characters used are Ctrl-D for directory name completion and Ctrl-F for file name completion. To disable a particular completion character in the registry, use the value for space (0x20) as it is not a valid control character.
Completion is invoked when you type either of the two control characters. The completion function takes the path string to the left of the cursor appends a wild card character to it if none is already present and builds up a list of paths that match. It then displays the first matching path. If no paths match, it just beeps and leaves the display alone. Thereafter, repeated pressing of the same control character will cycle through the list of matching paths. Pressing the Shift key with the control character will move through the list backwards. If you edit the line in any way and press the control character again, the saved list of matching paths is discarded and a new one generated. The same occurs if you switch between file and directory name completion. The only difference between the two control characters is the file completion character matches both file and directory names, while the directory completion character only matches directory names. If file completion is used on any of the built in directory commands (CD, MD or RD) then directory completion is assumed.
The completion code deals correctly with file names that contain spaces or other special characters by placing quotes around the matching path. Also, if you back up, then invoke completion from within a line, the text to the right of the cursor at the point completion was invoked is discarded.
The special characters that require quotes are: <space> &()[]{}^=;!'+,`~ | Moderiert von Tino: Quote-Tags hinzugefügt.
|
|
rob87
      
Beiträge: 461
Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
|
Verfasst: Do 09.08.07 09:15
| Zitat: |
Ich denke, er meint etwas, wie Batch-Code ausführen... Dazu müsstest du per SaveToFile eine .bat Datei erzeugen und diese mit ShellExecute aufrufen ... oder ... war das der Fall, bei dem man kein Shellexecute benutzen kann? |
Hallo erstmal,
ich weiß gar nicht, ob sie's wussten aber... ich hab ein Problem. *g*
Ich hab eine Batch-Datei zur Steuerung bzw. Veränderung der IP-Adressen.
Code: 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: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78:
| cls @echo off MODE CON LINES=32 MODE CON COLS=37 setlocal :menue cls color 70 echo. echo =================================== echo = = echo = Bitte waehlen sie ein Profil! = echo = = echo =================================== echo. echo =================================== echo = = echo = 1: Daheim (DHCP) = echo = 2: Arbeit (100.20) = echo = 3: Arbeit2 (106.29) = echo = 0: Menue verlassen = echo = = echo =================================== echo. set /p Auswahl= IF "%Auswahl%"=="1" goto daheim IF "%Auswahl%"=="2" goto arbeit IF "%Auswahl%"=="3" goto arbeit2 IF "%Auswahl%"=="0" goto exit
:daheim cls echo. echo =================================== echo = = echo = Einstellungen aendern fuer: = echo = = echo = * LAN-Verbindung 2 = echo = = echo = IP Adresse: DHCP = echo = Subnetzmaske: DHCP = echo = Gateway: DHCP = echo = DNS: DHCP = echo = = echo = * Drucker = echo = = echo = Canon PIXMA IP1600 = echo = = echo =================================== echo. netsh interface ip set address "Drahtlose Netzwerkverbindung" dhcp netsh interface ip set dns "Drahtlose Netzwerkverbindung" dhcp rundll32 printui.dll,PrintUIEntry /y /n "Microsoft Image Writer" goto ausgang
echo = Hab mal übersichtshalber einen Teil weggelassen =
:ausgang echo. echo =================================== echo = = echo = Einstellungen wurden gesetzt. = echo = = echo = Zum Beenden, beliebige Taste! = echo = = echo =================================== PAUSE > Nul EXIT :exit EXIT |
Nun würde ich das gerne grafisch mit Buttons usw. machen. Ich hab gehört, dass das mit ShellExecute ganz gut geht. Aber ich hab davon absolut keine Ahnung.
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 09.08.07 09:37
Moin!
Schau mal hier, damit sollte das auch möglich sein.
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
rob87
      
Beiträge: 461
Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
|
Verfasst: Do 09.08.07 10:06
Hallo,
vielen Dank. Aber wenn ich ehrlich bin hab ich von dem Quelltext der da drin steht keinen blassen Schimmer.
Ich will einfach nur meinen Batch-Quelltext in einen ButtonClick integrieren.
Bitte helft mir. Aber mir muss mas ganz einfach erklären. Vll. könnt mir einer des mit einem Button zeigen.
Bsw.: Button 1 führt die Batch-Datei aus, die die IP-Adresse xy ändert.
Was ich weiß, is:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
| procedure TipMainF.Button1Click(Sender: TObject); var e: integer; begin
e := ShellExecute (Handle, NIL, PCHAR('L:\ip.BAT'), PCHAR(''), NIL, SW_SHOW); end; |
Allerdings bringt er bei mir dann die Fehlermeldung ShellExecute nicht bekannt. Aber des is ja auch nur fast des was ich will.
Also soweit ichs nun herausgefunden hab, dass ich einen Batch-Code nicht einfach so ein Delphi implementieren kann. Ich muss eine Batch-Datei erstellen und dann via ShellExecute die Batch-Datei aufrufen.
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 09.08.07 10:21
Moin!
rob87 hat folgendes geschrieben: | | Also soweit ichs nun herausgefunden hab, dass ich einen Batch-Code nicht einfach so ein Delphi implementieren kann. Ich muss eine Batch-Datei erstellen und dann via ShellExecute die Batch-Datei aufrufen. |
Nein, das stimmt nicht, die im FAQ-Beitrag angegebene Funktion tut genau das, was du willst, aber eben immer nur einen Befehl, ggfs. also mehrfach aufrufen.
In dem FAQ-Beitrag ist ein Demo-Programm drin, schonmal reingesehen?
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
rob87
      
Beiträge: 461
Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
|
Verfasst: Do 09.08.07 10:26
Ich hab den FAQ-Bereich nicht gefunden. Aus der Delphi-Hife oder?
Meine Erkenntnis stütz ich momentan nur auf Beiträge ausm Forum.
Aber könntest mir schnell sagen, ob ich die ShellExecute irgendwo in bekanntgeben muss, damit ich se hernehmen kann. Wenn ich se allerdings in der Uses hinzufüg meckert er auch.
Zuletzt bearbeitet von rob87 am Do 09.08.07 10:31, insgesamt 1-mal bearbeitet
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 09.08.07 10:29
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
rob87
      
Beiträge: 461
Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
|
Verfasst: Do 09.08.07 10:33
Vielen Dank.
Batch-Datei ausführen haut hin. Nun wär halt, wie so ein Batch-Code Stück für Stück in Delphi implementiert wird. Könntest du mir von dem Beispiel-Programm einen Link schicken. Ich weiß grad, ned wo du des findest.
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 09.08.07 10:36
Narses hat folgendes geschrieben: | Moin!
Schau mal hier, damit sollte das auch möglich sein.
cu
Narses |
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
rob87
      
Beiträge: 461
Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
|
Verfasst: Do 09.08.07 10:39
Tut Mir Leid, aber davon versteh ich nur Bahnhof
Moderiert von AXMD: Unnötiges Zitat entfernt
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 09.08.07 10:59
rob87 hat folgendes geschrieben: | | Tut Mir Leid, aber davon versteh ich nur Bahnhof |
Dann solltest du in Erwägung ziehen, dass die Batchdatei weiterhin mit einem Doppelklick zu starten, vielleicht die beste Lösung ist... 
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
rob87
      
Beiträge: 461
Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
|
Verfasst: Do 09.08.07 12:40
Dann muss ich halt die Batch-Dateien immer mitzerren.
Nene. Ich guck mir des nochmal an.
Wenn ich des Programm dann mit integrierter Batch-Datei hab, kann ichs dir ja mal zur Verfügung stellen, wennst willst.
Aber könntest du mir vll. trotzdem nen Link von dem Demo-Programm aus den FAQ schicken?
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 09.08.07 13:52
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|