السلام عليكم عندي استفسار
طبقت هذا الكود في Delphi XE وعمل بنجاح
واعدت تطبيقه في Delphi XE Android ثم جربته في الهاتف تخرج لي الرسالة
Division by zero
طبقت هذا الكود في Delphi XE وعمل بنجاح
واعدت تطبيقه في Delphi XE Android ثم جربته في الهاتف تخرج لي الرسالة
Division by zero
كود :
function CalculateCode(LicenseName: string): string;
var
i, Code: integer;
CodeStr: string;
Num: Int64;
FSeed: Int64;
FRegCodeSize: integer;
begin
FSeed := 3210;
FRegCodeSize := 13;
// You can modify this algorithm if you want to...
if (Length(LicenseName) > 21) or (Length(LicenseName) < 4) then
begin
Result := ''; // LicenseName did not fit length requirements
Exit;
end;
i := Length(LicenseName);
// Takes the last 6 characters (going backwards), converting each
// character to ASCII and taking the remainder of dividing it into Seed
while (i >= Length(LicenseName) - 8) and (i > 0) do
begin
CodeStr := CodeStr + IntToStr(FSeed mod Ord(LicenseName[i]));
Dec(i);
end;
Val(CodeStr, Num, Code);
if FRegCodeSize <= 0 then
Result := IntToHex(Num, 0)
else
begin
Result := IntToHex(Num, FRegCodeSize);
Delete(Result, FRegCodeSize + 1, Length(Result) - FRegCodeSize);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text := CalculateCode(Edit1.Text);
end;
