我正在使用 Delphi XE IDE。我创建了一个通知器来实现 IOTACompileNotifier。在 IDE 中安装专家后。当我编译我的项目时,代码工作正常。通知程序正在为 ProjectCompileStarted 工作。
第二次编译我的项目,Delphi IDE提示:
[Fatal Error] Access violation at address 21B7FBED in module 'delphicoreide150.bpl'. Read of address 00000000
虽然我的表现看起来很奇怪:
var i: integer;
begin
i := Project.ProjectBuilder.AddCompileNotifier(TProjectCompileNotifier.Create);
Project.ProjectBuilder.RemoveCompileNotifier(i);
end;
在通知者中。我只想显示无论我如何使用,ProjectBuilder 的 Add and Remove compile notifier 似乎都无法正常工作。
请告知我应该如何实施 IOTAProjectCompileNotifier。
谢谢你。
以下是完整的源代码:
type
TProjectCompileNotifier = class(TInterfacedObject, IOTAProjectCompileNotifier)
protected
procedure AfterCompile(var CompileInfo: TOTAProjectCompileInfo);
procedure BeforeCompile(var CompileInfo: TOTAProjectCompileInfo);
procedure Destroyed;
end;
TCompileNotifier = class(TInterfacedObject, IOTACompileNotifier)
protected
procedure ProjectCompileStarted(const Project: IOTAProject; Mode: TOTACompileMode);
procedure ProjectCompileFinished(const Project: IOTAProject; Result: TOTACompileResult);
procedure ProjectGroupCompileStarted(Mode: TOTACompileMode);
procedure ProjectGroupCompileFinished(Result: TOTACompileResult);
end;
procedure TCompileNotifier.ProjectCompileStarted(const Project: IOTAProject;
Mode: TOTACompileMode);
var i: integer;
begin
i := Project.ProjectBuilder.AddCompileNotifier(TProjectCompileNotifier.Create);
Project.ProjectBuilder.RemoveCompileNotifier(i);
end;
var i: integer;
initialization
i := (BorlandIDEServices as IOTACompileServices).AddNotifier(TCompileNotifier.Create);
finalization
(BorlandIDEServices as IOTACompileServices).RemoveNotifier(i);
end.