开发者

C# Com Enum and VB6

开发者 https://www.devze.com 2023-04-05 07:26 出处:网络
Hi I created C# Exe Com Server and refer it from VB6 application. The problem is that all the enums are exposed with \"strange name\" in the vb app: EnumName_EnumeItem, while reffered from then VB6 co

Hi I created C# Exe Com Server and refer it from VB6 application. The problem is that all the enums are exposed with "strange name" in the vb app: EnumName_EnumeItem, while reffered from then VB6 code as EnumName.EnumItem.

The VB6 application code cannot be modified. Wondering around I saw I can change this definitions by changing the idl extract fro the tlb, but failed to understand exactly how it's done, and what are the tools for the job.

Any sugg开发者_高级运维estions how to set the enums easily as possible?

The code:

 public enum enResultCode : uint
{
    enRCNone = 0x00000000,
    enRCNotFound = 0x00000001,
    enRCFoundOnServer = 0x00000002,
    enRCFoundOnLocal = 0x00000003,
    enRCDatabaseError = 0x00000004,
    enRCAborted = 0xFFFFFFFF,
    enRCServerError = 0xFFFFFFFE,
    enRCLocalError = 0xFFFFFFFD
}

Shown in VB6 as:

C# Com Enum and VB6

instead of:

enResultCode.EnumItemName


I think you're correct the only way to do this is to modify the IDL yourself. I can tell you a little about how it's done...

  1. You run tlbexp.exe to create the tlb from your C# assembly.
  2. You run oleview.exe to open that tlb and inspect the IDL. You can save that IDL out to a file or copy/paste it.
  3. You edit the IDL to give it the enum item names you want.
  4. You run midl.exe to generate a tlb from your modified IDL.

That should be enough. Sorry I can't give you all the correct command line switches but I'm not on a Windows machine right now.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号