gpt4 book ai didi

delphi - IOTAProjectResource 是否在 Delphi XE2(也可能是 XE3)中损坏(再次!)?

转载 作者:行者123 更新时间:2023-12-03 18:48:46 25 4
gpt4 key购买 nike

我正在为 this question 做一些跑腿工作,具体来说,对于以下句子:

I even could not get this interface from IOTAProject.



作者 再次我的意思是 Delphi 2005 和 2006 中存在的众所周知的缺陷 outlined by Erik Berry .请访问链接的 QC 条目以获取完整的测试用例。

足够的话,这是我的代码:
procedure TResDumpWizard.Execute;
var
Project: IOTAProject;
Resource: IOTAProjectResource;
I: Integer;
Entry: IOTAResourceEntry;
begin
Project := (BorlandIDEServices as IOTAModuleServices).GetActiveProject;
Assert(Assigned(Project), 'No active project');

Resource := nil;
for I := 0 to Project.ModuleFileCount - 1 do
begin
if Supports(Project.ModuleFileEditors[I], IOTAProjectResource, Resource) then
Break;
end;
Assert(Assigned(Resource), 'No resources in project'); // (!!!) always fails

for I := 0 to Resource.GetEntryCount - 1 do
begin
Entry := Resource.GetEntry(I);
(BorlandIDEServices as IOTAMessageServices).AddTitleMessage(DisplayName(Entry.GetResourceName));
end;
end;

即使项目有额外的资源,循环遍历项目的模块文件编辑器也永远找不到任何资源
  • 通过资源和图像对话框添加
  • 使用 {$RESOURCE binary.res}指令
  • 使用 {$R filename.res filename.rc}不再有效的语法
  • 最佳答案

    (我的声誉很低,所以无法添加评论)

    Project.ModuleFileCount 总是返回 1 并且 Project.ModuleFileEditors[0].FileName 返回 ProjectName.dpr

    在我测试的 XE3 中,可以使用以下代码枚举项目的所有模块:

    var i, j: Integer;
    Resource: IOTAProjectResource;
    ModuleInfo: IOTAModuleInfo;
    Module: IOTAModule;
    Editor: IOTAEditor;

    Resource := nil;
    for i := 0 to Project.GetModuleCount - 1 do
    begin
    ModuleInfo := Project.GetModule(i);
    try
    Module := ModuleInfo.OpenModule; // can raise exception
    for j := 0 to Module.ModuleFileCount - 1 do
    begin
    Editor := Module.ModuleFileEditors[j];
    if Supports(Editor, IOTAProjectResource, Resource) then
    Break;
    end;
    except
    end;
    if Assigned(Resource) then Break;
    end;
    if not Assigned(Resource) then
    MessageBox(0, 'Not found!!!', 'Info', 0);

    但无论如何我一直没有找到!!!信息。

    关于delphi - IOTAProjectResource 是否在 Delphi XE2(也可能是 XE3)中损坏(再次!)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20823908/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com