Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
Delphi 6 Personal
|
Re: Ersatz für Batch Befehl CHOICE ?
13. Mai 2006, 11:00
Das soll nicht funktionieren ?
Delphi-Quellcode:
program Dings;
{$APPTYPE CONSOLE}
uses
Windows;
procedure Exec(FullFileName: String);
var
Err : Integer;
begin
Err := WinExec(@FullFileName[1], SW_SHOWNORMAL);
if Err <= 31 then
begin
WriteLn(' '' '+FullFileName+' '' ');
case Err of
0 : WriteLn(' The system is out of memory or resources.');
ERROR_BAD_FORMAT : WriteLn(' The .EXE file is invalid (non-Win32 .EXE'+
' or error in .EXE image).');
ERROR_FILE_NOT_FOUND : WriteLn(' The specified file was not found.');
ERROR_PATH_NOT_FOUND : WriteLn(' The specified path was not found.');
else WriteLn(' Unkown Error');
end;
// Halt;
end;
end;
procedure WriteChars(AnyChar: Char; Count: Word; NewLine: Boolean);
var i: Word;
begin
for i := 0 to Count do
Write(AnyChar);
if NewLine then Writeln;
end;
function MyStrToInt(s: string; var i: integer): Boolean;
var
Err: Integer;
begin
val(s, i, err);
if err <> 0 then MyStrToInt := False
else MyStrToInt := True;
end;
var
s: string;
n: Integer;
begin
WriteLn;
WriteChars(' -', 40, TRUE);
WriteLn;
WriteLn(' [1] - Dell Latitude C840');
WriteLn(' [2] - PC001');
WriteLn(' [3] - Abbruch');
WriteLn;
WriteChars(' -', 40, TRUE);
WriteLn;
repeat
Write(' Ihre Auswahl: ');
Readln(s);
if MyStrToInt(s, n) then
begin
case n of
1: Exec(' c:\net\netbind.com');
2: Exec(' c:\net\net.exe');
3: WriteLn(' Abbruch durch User.');
else Write(' Unzulaessige Eingabe. ');
end;
end else
Write(' Unzulaessige Eingabe. ');
until n in [1..3];
end.
|
|
Zitat
|