Re: String access error in class
- From: Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@xxxxxxxxxxx>
- Date: Thu, 27 Mar 2008 19:07:48 -0500
E Sterrett wrote:
I have included a stripped down version of a class I am using to store configuration data in an ini file.Try calling the inherited create first maybe?
This works when I am using it from a simple console app. But when I include it in a larger project, the constructor throws this error:
'Access violation at address 004050FC in module 'app.exe'. Write of address 00000008'.
This happens on the line: ComputerName:='test';
Obviously 00000008 is not a valid address. But I thought delphi handles string address automatically.
What have I done wrong?
Thanks.
unit Configuration;
interface
uses windows,inifiles,sysutils;
type
TConfig = Class(TObject)
public
FileName:string;
ComputerName:String;
//...
constructor Create(); overload;
constructor Create(FN:String); overload;
//procedure saveFile(); overload;
//procedure saveFile(FN:string); overload;
//function checkErrors():string;
//procedure fixErrors();
end;
var
IniFile : TIniFile;
implementation
constructor TConfig.Create(Fn:string)overload;
begin
IniFile := TIniFile.Create(Fn);
ComputerName:='test';
filename:=fn;
//savefile(fn);
end;
constructor TConfig.Create()overload;
begin
Create(Paramstr(0)+'.ini');
end;
end.
http://webpages.charter.net/jamie_5"
.
- Follow-Ups:
- Re: String access error in class
- From: Maarten Wiltink
- Re: String access error in class
- References:
- String access error in class
- From: E Sterrett
- String access error in class
- Prev by Date: Re: String access error in class
- Next by Date: Re: String access error in class
- Previous by thread: String access error in class
- Next by thread: Re: String access error in class
- Index(es):
Relevant Pages
|