String access error in class
- From: E Sterrett <bgreenf@xxxxxxxxxxxxx>
- Date: Thu, 27 Mar 2008 20:01:37 +0000
I have included a stripped down version of a class I am using to store configuration data in an ini file.
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.
.
- Follow-Ups:
- Re: String access error in class
- From: Jamie
- Re: String access error in class
- Prev by Date: Re: D2006 Object inspector component
- Next by Date: Re: String access error in class
- Previous by thread: Getting TWebbrowser contents HTML into a string
- Next by thread: Re: String access error in class
- Index(es):
Relevant Pages
|