简体   繁体   English

如何保持生成的TLB文件整洁?

[英]How to keep the generated TLB file neat?

Hi I use interop to call C# code in Delphi. 嗨,我使用互操作在Delphi中调用C#代码。 C# code has a binary and in Delphi 5 Menu: Project-->Import Type Library Click Add to add the tlb file: XXXX.tlb Unit dir name: input the path where the delphi XXX_TLB.pas file is generated. C#代码具有二进制文件,在Delphi 5菜单中:项目->导入类型库单击添加以添加tlb文件:XXXX.tlb单元目录名称:输入生成delphi XXX_TLB.pas文件的路径。

If the C# dll, tlb and delphi XXX_TLB.pas has already been there. 如果C#dll,tlb和delphi XXX_TLB.pas已经存在。 Now I add one more function in C# code and hope Delphi can call this function as well. 现在,我在C#代码中添加了另一个函数,希望Delphi也可以调用此函数。 I need to recompile c# and regenerate delphi XXX_TLB.pas file. 我需要重新编译c#并重新生成delphi XXX_TLB.pas文件。 But by following the above steps, I see the newly generated XXX_TLB.pas includes my newly added function, but looks like the functions order in XXX_TLB.pas is totally different from before. 但是通过执行上述步骤,我看到了新生成的XXX_TLB.pas包括我新添加的函数,但是看起来XXX_TLB.pas中的函数顺序与以前完全不同。

For example, in my C# binary I have function: func1(); 例如,在我的C#二进制文件中,我具有以下功能:func1(); func2(); FUNC2(); func3(); FUNC3(); func4();//newly added func4(); //新添加

In the old XXX_TLB.pas, the function order is: func1(); 在旧的XXX_TLB.pas中,功能顺序为:func1();。 func2(); FUNC2(); func3(); FUNC3(); Now XXX_TLB.pas is like this: func1(); 现在XXX_TLB.pas像这样:func1(); func3(); FUNC3(); func4(); FUNC4(); func2(); FUNC2();

The XXX_TLB.pas can still be used, looks like no functionality difference, but when I check in to tfs, I see it changes a lot from pervious version. XXX_TLB.pas仍然可以使用,看起来没有功能差异,但是当我签入tfs时,我发现它与以前的版本有很大的不同。 Is there a way to keep this new XXX_TLB.pas the same order as before but add my function as well? 有没有办法使这个新的XXX_TLB.pas保持与以前相同的顺序,同时还要添加我的功能? How to do that? 怎么做? Thanks! 谢谢!

You cannot hope to keep the changes to a minimum unless you start writing the .pas file yourself. 除非您自己开始编写.pas文件,否则您不能希望将更改降至最低。 That sounds like a worse option. 这听起来是一个更糟糕的选择。

Probably what is happening is that you have changed version of either one of your compilers since the last time you imported. 可能发生的情况是,自上次导入以来,您已经更改了任一编译器的版本。 Otherwise one would expect minimal differences. 否则,人们会期望差异最小。

Just check it in with a comment stating which versions of compiler and .ocx/.dll were used. 只需在注释中注明使用了哪个版本的编译器和.ocx / .dll即可。

You can't, as far as I know. 据我所知你不能。 I most cases, I'm able to consider them as a sort of "black box" anyway, and only occasionally have to peek in them to find a specific declaration. 在大多数情况下,无论如何,我都可以将它们视为一种“黑匣子”,并且仅偶尔需要窥视它们才能找到特定的声明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM