Hi,
ich hab´dir mal den Code etwas formatiert...
Dann hat man bessere Übersicht, weiß wo ein
begin anfängt und wo das dazugehörige end steht etc.
Das mit dem goto ist ein no-go
Wird im allgemeinen als schlechter Programmierstil angesehen,
weil der Programmfluss nicht mehr so einfach zu durchschauen ist.
Versuch doch mal, das Programm in einzelne Prozeduren/Funktionen zu
unterteilen. Dann wird der Hauptteil übersichtlicher und du brauchst
(hoffentlich) keine goto´s mehr
Delphi-Quellcode:
program Security1Beta;
{$APPTYPE CONSOLE}
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
shellapi;
var Passwort, compname, test:
String;
Wrongcount: Integer = 0;
label anfang, ende, EnterComputerName;
begin
if DirectoryExists(test+'
_Desktop')
then WrongCount := 4;
anfang:
Write('
Please enter Password to access: ');
ReadLn(Passwort);
writeln;
if (passwort = '
passwort1')
and (wrongcount < 4)
then
begin
writeln('
Access...');
goto ende;
end else if wrongcount < 4
then
begin
writeln('
Access denied!!! You can try one more.');
inc(wrongcount);
end else begin
writeln('
Access to all functions of the program will be blocked...');
writeln('
Another entering the password is no longer possible.');
EnterComputerName:
CreateDir(test+'
_Desktop');
writeln('
Please identify yourself as the owner of this computer.');
writeln;
write('
Please enter the computer name: ');
ReadLn(compname);
if compname = GetEnvironmentVariable('
USERDOMAIN')
then
begin
writeln;
writeln('
Computer name is checked...');
writeln;
writeln('
Computer name confirmed.');
RemoveDir(test+'
_Desktop');
wrongcount:= 0;
writeln;
goto anfang;
end else begin
writeln;
writeln('
Computer name is checked...');
writeln;
writeln('
Wrong input.');
writeln('
Full closure is initialized...');
writeln('
Full closure in Progress...');
CreateDir(test+'
_Lokale Einstellungen');
writeln('
Full closure complete.');
goto EnterComputerName
end;
end;
writeln;
goto anfang;
ende:
writeln;
write('
To end the program press enter.');
ReadLn;
end.