DelphiX无缘无故引起的Access Violation问题!
新建unit2,贴上下面代码:
unit Unit2;
interface
uses
Forms,DXDraws;
type TDX=class
DirectX:TDXDraw;
constructor Create(Owner:TForm);
destructor Free();
end;
implementation
constructor TDX.Create(Owner:TForm);
begin
if DirectX=nil then begin
DirectX:=TDXDraw.Create(Owner);
DirectX.Parent:=Owner;
DirectX.Initialize();
DirectX.Visible:=true;
end;
end;
destructor TDX.Free();
begin
if DirectX <>nil then begin
DirectX.Free();DirectX:=nil;
end;
end;
end.
在主unit里加入下面代码(记得在uses里添加DXDraws,unit2):
procedure TForm1.Button1Click(Sender: TObject);
var i:Integer;dx:array [0..1] of TDX;
begin
for i:=1 to 2 do begin //第2次发生错误
dx[0]:=TDX.Create(Self);
dx[1]:=TDX.Create(Self);
dx[0].Free();dx[0]:=nil;
dx[1].Free();dx[1]:=nil;
end;
end;
它有2次循环,第1次没发生错误,第2次循环时发生错误。我试过达到这样的条件时才会有错:1.必须是以类的形式把DelphiX包含在类里,2.必须是数组,例如dx,如果是单个则不会发生错误.
指针释放好像没问题,到底是什么问题?谢谢!
dx[0]:=TDX.Create(Self);
dx[0].Free();dx[0]:=nil;
这样试一下
dx[1]:
相关问答:
IsSqlDataBase = 0 '主数据库类型(1=SQL,0=AC)
'===========================================================================
SqlDatabaseName = "ads365" '主数据库名
S ......
access 中执行sql update语句时有时候成功有时候不成功,但是access中不出错误信息,不知道是什么原因,有哪位大侠知道,请帮忙啊
贴SQL语句,检查表、字段的有效性设置
sql 在查询分析器里面 执行很正常
是 ......
<?php
include("adodb/adodb.inc.php");
$db = &NewADOConnection("access");
$access = realpath("Data.mdb");
$dsn = "Provider=Microsoft.J ......
表结构:
ProductSeriesID 自动编号
ProductSeriesName 文本
ProductSeriesRemark 备注
执行前
ProductSeriesID ProductSeriesName ProductSeriesRemark
2 LV铣刀系列 LV铣刀系列
3 钨钢舍 ......