当前位置: 技术问答>java相关
指针非法操作,看看如何处理?
来源: 互联网 发布时间:2015-07-31
本文导语: var File1:TFileStream; Buffer:PChar; Size:Integer; FileName:String; IniInfo:String; begin FileName := GetApplicationPath + 'Fkcz.sys'; if FileExists(FileName) then ...
var
File1:TFileStream;
Buffer:PChar;
Size:Integer;
FileName:String;
IniInfo:String;
begin
FileName := GetApplicationPath + 'Fkcz.sys';
if FileExists(FileName) then
begin
File1 := TFileStream.Create(FileName,fmOpenRead);
File1.Position := 0;
GetMem(Buffer,File1.Size);
File1.Read(Buffer,File1.Size);
IniInfo := String(Buffer);
FreeMem(Buffer);
File1.Free;
end;
File1 := TFileStream.Create(FileName,fmCreate);
File1.Position := 0;
Size := Length('#' + Section + Ident + Inttostr(Length(Value)) + Value);
GetMem(Buffer,Size);
Buffer := PChar('#' + Section + Ident + Inttostr(Length(Value)) + Value);
File1.Write(Buffer,Size);
FreeMem(Buffer);非法指针操作?????
File1.Free;
File1:TFileStream;
Buffer:PChar;
Size:Integer;
FileName:String;
IniInfo:String;
begin
FileName := GetApplicationPath + 'Fkcz.sys';
if FileExists(FileName) then
begin
File1 := TFileStream.Create(FileName,fmOpenRead);
File1.Position := 0;
GetMem(Buffer,File1.Size);
File1.Read(Buffer,File1.Size);
IniInfo := String(Buffer);
FreeMem(Buffer);
File1.Free;
end;
File1 := TFileStream.Create(FileName,fmCreate);
File1.Position := 0;
Size := Length('#' + Section + Ident + Inttostr(Length(Value)) + Value);
GetMem(Buffer,Size);
Buffer := PChar('#' + Section + Ident + Inttostr(Length(Value)) + Value);
File1.Write(Buffer,Size);
FreeMem(Buffer);非法指针操作?????
File1.Free;
|
File1.Free后加exit