源代码如下:
//DLL创建
procedure TYW1Drive.BuildMenu;
var
NewItem:TMenuItem;
begin
//其中FormMain是参数传入的;
FMainMenu:=TMainMenu(FormMain.FindComponent('MainMenu'))
NewItem := TMenuItem.Create(nil);
FMainMenu.Items.Items[0].Add(newItem);
newItem.Caption:='dddd'; NewItem := TMenuItem.Create(nil);
FMainMenu.Items.Items[0].Add(newItem);
newItem.Caption:='dddddd';
end;
//DLL退出时释放
for i:=FMainMenu.Items.Items[0].Count-1 downto 0 do
begin
MenuItem:= FMainMenu.Items.Items[0].items[I];
FMainMenu.Items.Items[0].Delete(I);
if Assigned(MenuItem) then
MenuItem.Free;
end;主程序关闭的时候,出现
Application Error
Exception EAccessViolatio in module PKJ.exe at 00003194
Access violation at address 00403194 in module 'PKJ.exe' read of address 00FA7940
//DLL创建
procedure TYW1Drive.BuildMenu;
var
NewItem:TMenuItem;
begin
//其中FormMain是参数传入的;
FMainMenu:=TMainMenu(FormMain.FindComponent('MainMenu'))
NewItem := TMenuItem.Create(nil);
FMainMenu.Items.Items[0].Add(newItem);
newItem.Caption:='dddd'; NewItem := TMenuItem.Create(nil);
FMainMenu.Items.Items[0].Add(newItem);
newItem.Caption:='dddddd';
end;
//DLL退出时释放
for i:=FMainMenu.Items.Items[0].Count-1 downto 0 do
begin
MenuItem:= FMainMenu.Items.Items[0].items[I];
FMainMenu.Items.Items[0].Delete(I);
if Assigned(MenuItem) then
MenuItem.Free;
end;主程序关闭的时候,出现
Application Error
Exception EAccessViolatio in module PKJ.exe at 00003194
Access violation at address 00403194 in module 'PKJ.exe' read of address 00FA7940
解决方案 »
- cxgrid的boolean类型的列,绑定到数据表的bit类型字段,字段默认值为0,
- 求D2010支持png格式图片的方法
- DBGrid转EXCLE时候身份证号码最后3位显示为0(急!!!)
- 用友政务Delphi软件工程师(人数:5)[email protected] 010-82613388-5002 别删好不好
- 一个messagebox问题!
- 在互联网上实现计算机间的通信
- procedure Tform1.table1calcfields(Dataset:Tdataset);这句在如何写?
- 这个存储过程怎么执行??//牛虻
- 请教一个关于DECISION CUBE组件的问题!!
- 这里应该有很多"码友"用过VC吧?VC对系统/COM支持特别好,为什么Delphi高手不来为Delphi从新封装VC的一些好东东?
- 真邪门,单单不能捕获ALT键
- 怎样才能让DBGrid捕捉鼠标的滚动事件(100分问题)
begin
MenuItem:= FMainMenu.Items.Items[0].items[I];
FMainMenu.Items.Items[0].Delete(I);
if Assigned(MenuItem) then
MenuItem.Free;
end;释放的时候,直接释放对象就完了,没有必要一个一个删除item
uses
SysUtils,
Classes,
Menus,
Forms,
Windows;var FMainMenu: TMainMenu;
DLLAPP: TApplication;
DllScr: TScreen;{$R *.res}procedure BuildMenu(aForm: TForm; App: TApplication; src: TScreen);stdcall;
var
NewItem:TMenuItem;
begin
Application := App;
Screen := src;
FMainMenu := TMainMenu(aForm.FindComponent('MainMenu'));
NewItem := TMenuItem.Create(nil);
newItem.Caption:='测试';
FMainMenu.Items.Add(newItem);
NewItem := TMenuItem.Create(nil);
newItem.Caption:='dddddd';
FMainMenu.Items.Items[0].Add(newItem);end;procedure DLL_UnLoadProc(Reason: Integer); register;
begin
if Reason = DLL_PROCESS_DETACH then
begin
Application := DLLAPP;
Screen := DllScr;
FMainMenu.Free;
end;
end;exports
BuildMenu name 'BuildMenu';begin
DLLAPP := Application;
DllScr := Screen;
DllProc := @DLL_UnLoadProc;end.
我做了测试没有问题,有问题联系我[email protected]