2

Hi I use interop to call C# code in Delphi. 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.

If the C# dll, tlb and delphi XXX_TLB.pas has already been there. Now I add one more function in C# code and hope Delphi can call this function as well. I need to recompile c# and regenerate delphi XXX_TLB.pas file. 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.

For example, in my C# binary I have function: func1(); func2(); func3(); func4();//newly added

In the old XXX_TLB.pas, the function order is: func1(); func2(); func3(); Now XXX_TLB.pas is like this: func1(); func3(); func4(); 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. Is there a way to keep this new XXX_TLB.pas the same order as before but add my function as well? How to do that? Thanks!

1
  • I trust it is just the class wrappers that are being reordered. That must not happen to the COM interfaces because it changes viable order. Jan 12, 2012 at 14:54

2 Answers 2

2

You cannot hope to keep the changes to a minimum unless you start writing the .pas file yourself. 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.

3
  • The old file is generated in XP system, and now I only have windows 7. So you think this might be the reason?
    – spspli
    Jan 13, 2012 at 14:23
  • I would have thought differences in compiler versions would actually be more likely to explain differences in output from the typelib importer. OS should not matter. Jan 13, 2012 at 14:26
  • I had a similar case were the old and new TLB.pas files differ significantly in their ordering (even classes are moved). I have changed neither the compiler nor the OS version. It's probably some implementation detail in the importer that Delphi uses. Jan 18, 2012 at 15:56
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.