以下为全局类
unit g_class_u;interfaceuses classes,SysUtils,Controls,mydata;Type
Tg_class=class(TObject)
public
class function create_G(usrcode:string):Tg_class;
function findpwd(Ival:integer):boolean;
destructor Destroy; override;
private
mypwr:array of integer;
constructor Create(val:string);//输入权限组end; var g_class:Tg_class;implementationconstructor Tg_class.Create(val: string);
var
Ssqlstr:string;
Inum:integer;
begin
inherited Create;
Ssqlstr:='select cFnNo from sysfunction where cFnno in (select CFnno from g_s where Gno='+val+') ';
with DataModule1.ADOQuery1 do
begin
close;
sql.clear;
sql.add(Ssqlstr);
open ;
if recordcount=0 then
begin
setlength(mypwr,1);
mypwr[0]:=0;
exit;
end;
setlength(mypwr,recordcount);
first;
for Inum:=0 to recordcount do
begin
mypwr[Inum]:=fieldbyname('cFnNo').asinteger;
next;
end;
close;
end;
end;class function Tg_class.create_G(usrcode: string): Tg_class;
begin
if (g_class=nil) then
g_class:=Tg_class.create(usrcode);
result:=g_class;
end;destructor Tg_class.Destroy;
begin // setLength(myPwr,0);
// myPwr:=nil;
// inherited Destroy;
end;function Tg_class.findpwd(Ival: integer): boolean;
var
Inum:integer;
begin for Inum:=low(mypwr) to high(mypwr) do
begin
if mypwr[Inum]=Ival then
begin
result:=true;
exit;
end;
end;
result:=false;
end;end.然后在一个窗体中procedure TMyForm1.FormShow(Sender: TObject);
begin
if g_class=nil then
g_class:=Tg_class.create_G(grpname);
end;procedure TMyForm1.FormDestroy(Sender: TObject);
begin
if g_class<>nil then
FreeAndNil(g_class);
end;怎么会出现错误呢! 各位帮着看看 我用是单例模式写的全局类 为什么我退出释放g_class的时候会出错!
unit g_class_u;interfaceuses classes,SysUtils,Controls,mydata;Type
Tg_class=class(TObject)
public
class function create_G(usrcode:string):Tg_class;
function findpwd(Ival:integer):boolean;
destructor Destroy; override;
private
mypwr:array of integer;
constructor Create(val:string);//输入权限组end; var g_class:Tg_class;implementationconstructor Tg_class.Create(val: string);
var
Ssqlstr:string;
Inum:integer;
begin
inherited Create;
Ssqlstr:='select cFnNo from sysfunction where cFnno in (select CFnno from g_s where Gno='+val+') ';
with DataModule1.ADOQuery1 do
begin
close;
sql.clear;
sql.add(Ssqlstr);
open ;
if recordcount=0 then
begin
setlength(mypwr,1);
mypwr[0]:=0;
exit;
end;
setlength(mypwr,recordcount);
first;
for Inum:=0 to recordcount do
begin
mypwr[Inum]:=fieldbyname('cFnNo').asinteger;
next;
end;
close;
end;
end;class function Tg_class.create_G(usrcode: string): Tg_class;
begin
if (g_class=nil) then
g_class:=Tg_class.create(usrcode);
result:=g_class;
end;destructor Tg_class.Destroy;
begin // setLength(myPwr,0);
// myPwr:=nil;
// inherited Destroy;
end;function Tg_class.findpwd(Ival: integer): boolean;
var
Inum:integer;
begin for Inum:=low(mypwr) to high(mypwr) do
begin
if mypwr[Inum]=Ival then
begin
result:=true;
exit;
end;
end;
result:=false;
end;end.然后在一个窗体中procedure TMyForm1.FormShow(Sender: TObject);
begin
if g_class=nil then
g_class:=Tg_class.create_G(grpname);
end;procedure TMyForm1.FormDestroy(Sender: TObject);
begin
if g_class<>nil then
FreeAndNil(g_class);
end;怎么会出现错误呢! 各位帮着看看 我用是单例模式写的全局类 为什么我退出释放g_class的时候会出错!
解决方案 »
- 高分求解答,dspack采集无驱动摄像头视频压缩问题!!
- 急!!!急!!!!!!!!!!!!关于MSCOMM转SPCOMM
- 如何用delphi的OLEContainer操控MS Word?
- 在www.2ccc.com上下载了几个版本的ExpressQuantumGrid 包括5及6的版本,可是不会安装,请大侠们帮忙啊。
- 非常诡异-我的DELPHI的主菜单没有了
- 在线等待,怎样的D中嵌入Flash
- 如何获得超过1000个字符以上的pchar??
- 在dbcombobox的Item中添加项目,但在使用时却不能选择,这是为何
- 我的Delphi程序的Exe文件,再没有装Delphi的机子上不能运行,
- 在delphi中如何读ini文件,用什么api,或者delhpi就有这些函数
- query组件操作,急救!
- 那里有delphi5 呀
begin
mypwr:=Nil;
if g_class<>nil then
FreeAndNil(g_class);
end;