Delphi 中的不兼容类型错误

Incompatible Types error in Delphi

我正在将应用程序从 Delphi 7 迁移到 Delphi XE5,以下是我的功能。

function InternalDecrypt(const S: AnsiString; Key: Word): AnsiString;
var
  I: Word;
  Seed: Word;
begin
  Result := S;
  Seed := Key;
  for I := 1 to Length(Result) do
  begin
    Result[I] := Char(Byte(Result[I]) xor (Seed shr 8)); //Error is here
    Seed := (Byte(S[I]) + Seed) * Word(C1) + Word(C2)
  end
end;

我的错误是:类型 'ansichar' 和 'char' delphi 不兼容,谁能以正确的方式指导我。

尝试

Result[I] := AnsiChar(Byte(Result[I]) xor (Seed shr 8));

将 c1 和 c2 作为 ansichar 类型。