В общем, проблема такая: перепробовал все способы открыть файлы - через tfilestream, textfile,file(ну я не знаю как объяснить лучше, просто это все типы указателей на файл которые перепробовал), везде вылетает сразу после открытия файла с access violation.
открытие идет через topendialog, я пробовал руками вбивать путь, все равно летит... вот код:
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DialogsX, StdCtrls, StrUtils, Buttons, Mask;
type
TForm1 = class(TForm)
flpndlg1: TFileOpenDialog;
btn1: TButton;
edt1: TEdit;
lbl1: TLabel;
medt1: TMaskEdit;
btn2: TBitBtn;
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
private
public
function encode(instring:string; StartKey, MultKey, AddKey: Integer):AnsiString;
procedure open_to_encode;
end;
const
StartKey = 248;
MultKey = 62142;
var
Form1: TForm1;
encoded:AnsiString;
input:TFileStream;
line:string;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
open_to_encode;
end;
function TForm1.encode(InString: string; StartKey, MultKey, AddKey: Integer):AnsiString;
var i: cardinal;
begin
Result := 'correct';
for i := 1 to Length(InString) do
begin
Result := Result + CHAR(Byte(InString[i]) xor (StartKey shr 8));
StartKey := (Byte(Result[i]) + StartKey) * MultKey + AddKey;
end;
end;
procedure TForm1.open_to_encode;
begin
if Form1.flpndlg1.Execute
then
begin
input.Create(form1.flpndlg1.FileName, fmOpenWrite, fmShareDenyWrite);
input.Read(line, input.Seek(0,soFromEnd));
end;
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
if Length (form1.medt1.Text) = 6 then
begin
encoded := encode(line, StartKey, MultKey, StrToInt(form1.medt1.Text));
Form1.edt1.Text:=encoded;
//input.Write(encoded,Length(encoded));
//input.Free;
end;
end;
end.
Помогите, пожалуйста. я уже не знаю, что можно сделать.