在Delphi中重命名DLL
假设我有一个用 Delphi 编写的大型 ActiveX 库,我们将其命名为 Lib1.dll。它包含多个接口。任务是将库重命名为Lib2.dll,以便另一个应用程序可以同时调用 Lib1 和 Lib2 中的两个方法。 我想用下面的方法来做:
- 将 Delphi 项目重命名为 Lib2 (这将重命名库)。
- 将 *Lib1_TLB.pas* 文件替换为 *Lib2_TLB.pas*,内容相同,但使用接口和组件类的新 GUID。
- 将新 GUID 粘贴到Lib2.ridl。
- 从该ridl 生成新的Lib2.tlb 文件,应该没问题。
但事实并非如此。我收到 Delphi 错误“找不到 Lib1.ridl 文件”。好的,将 rodl 和 tlb.pas 重命名回 Lib1,编译和构建正常,但是注册 ActiveX 服务器会使 IDE 崩溃。 请建议我一种重命名库的方法或如何使我当前的进度发挥作用。
Suppose I've got a large ActiveX library written in Delphi, let's call it Lib1.dll. It contains multiple interfaces. The task is to rename the library to Lib2.dll in such a way, that another application can call both methods from Lib1 and Lib2 at the same time.
I thought to do it in next way:
- Rename Delphi project to Lib2 (that will rename the library).
- Replace *Lib1_TLB.pas* file with *Lib2_TLB.pas* with the same content, but with new GUIDs of interfaces and coclasses.
- Paste new GUIDs to Lib2.ridl.
- Generate new Lib2.tlb file from that ridl and that should be ok.
But it isn't. I'm getting Delphi error "Couldn't find Lib1.ridl file". Okay, rename both ridl and tlb.pas back to Lib1, compile&build ok, but registering ActiveX server crashes the IDE.
Please suggest me a way to rename the lib or how to make my current progress work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您使用的是最新版本的 Delphi,使用 .ridl 文件作为 COM 接口,因此请记住,它是处理 COM 的中央单元。您可以首先将ridl 文件从Lib1.ridl 复制并重命名为Lib2.ridl。然后在 Lib2.ridl 内部,而不是 _TLB.pas(自动重新创建)重新生成库的 GUID 和 coclass 的 GUID。接口可能保持不变。之后,您应该能够生成 tlb 并刷新 _TLB.pas,最后构建并注册新库。
I assume you are using a recent version of Delphi using .ridl files for COM interfaces so keep in mind that it is the central unit for dealing with COM. You may start with copying and renaming the ridl file from Lib1.ridl to Lib2.ridl. Then inside Lib2.ridl, not _TLB.pas (which is recreated automatically) regenerate the library's GUID and those of coclasses. Interfaces may remain unchanged. After that you should be able to generate tlb and refresh _TLB.pas and finally build and register the new library.