关于类的问题。(100分)

  • 主题发起人 主题发起人 tianyu717
  • 开始时间 开始时间
T

tianyu717

Unregistered / Unconfirmed
GUEST, unregistred user!
我写的一个单元,但在其它单元中调用 AppIni:=TAppIni.Create; 出现错误提示。

‘Acess violation at address 004c4b9e in module 'tian.exe'.read of address FFFFFFFF’

请求大侠帮忙。



unit RegUnit;

interface
uses
IniFiles, SysUtils, Forms, Graphics, Main;

type
TAppIni=class
private
FileName:string;
public
//类成员函数
constructor Create;
destructor Destroy;override;
end;

const
csWidth='Width';
csHeight='Height';
csLeft='Left';
csTop='Top';
csState='State';
csVisible='Visible';
csColor='Color';
csFontName='FontName';
csFontSize='FontSize';
csFontColor='FontColor';
csFontStyle='FontStyle';
csReadOnly='Edit';
csWordWrap='WordWrap';

var
AppIni:TAppIni;

implementation


constructor TAppIni.Create;
var
i,n:integer;
Ini:TIniFile;
pStyles:pointer;
s:string;
begin
//求出应用程序的INI文件名
FileName:=Application.ExeName;
n:=Length(FileName);
FileName[n-2]:='i';
FileName[n-1]:='n';
FileName[n] :='i';
FileName:=LowerCase(FileName);

Ini:=TIniFile.Create(FileName);
with Ini do
begin
//MainFrom Section
with MainForm do
begin
s:=Name;
SetBounds(ReadInteger(s,csLeft,0),
ReadInteger(s,csTop,0),
ReadInteger(s,csWidth,Width),
ReadInteger(s,csHeight,Height));
WindowState:=TWindowState(ReadInteger(s,csState,integer(WindowState)));
end;
end;
end;

destructor TAppIni.Destroy;
var
i,n:integer;
Ini:TIniFile;
tmpStyles:TFontStyles;
pStyles:pointer;
s:string;
begin
Ini:=TIniFile.Create(FileName);
with Ini do
begin
//MainFrom Section
with MainForm do
begin
s:=Name;
WriteInteger(s,csState,integer(WindowState));
if WindowState<>wsNormal then //如果不为正常的话,
begin
WriteInteger(s,csWidth,540) ; //设为一个常值
WriteInteger(s,csHeight,411);
WriteInteger(s,csLeft,Screen.Height div 2); //各为桌面的一半!
WriteInteger(s,csTop,Screen.Width div 2)
end
else
begin
WriteInteger(s,csWidth,Width);
WriteInteger(s,csHeight,Height);
WriteInteger(s,csLeft,Left);
WriteInteger(s,csTop,Top);
end;
end;
Ini.Free;
end;

end.
 
我试过你的程序,一点问题都没有啊,运行正常!!
 
在我这里真的不行。
 
把你的.exe,.ini删了再编译一次
 
补充一下。
procedure Tmainform.create(sender);
begin
AppIni:=TAppIni.Create;
ADOQUERY1.open;
... ....
end;

我在过程只要同时调用ADOQUERY和APPINI就会出现上边的错误。
如只调用其中一个,程序却一切正常。这是不是DELPHI6的BUG。
ADOQUERY和APPINI不能在一个过程中同时调用。
help me.!!!!!!!
 
多人接受答案了。
 
后退
顶部