简体   繁体   English

C#Com Enum和VB6

[英]C# Com Enum and VB6

Hi I created C# Exe Com Server and refer it from VB6 application. 您好我创建了C#Exe Com Server并从VB6应用程序中引用它。 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. 问题是所有的枚举都在vb app:EnumName_EnumeItem中以“奇怪的名字”公开,而从VB6代码引用为EnumName.EnumItem。

The VB6 application code cannot be modified. VB6应用程序代码无法修改。 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. 想知道我能看到我可以通过改变tlb的idl提取来改变这个定义,但却无法准确理解它是如何完成的,以及这项工作的工具是什么。

Any suggestions 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: 在VB6中显示为:

在此输入图像描述

instead of: 代替:

enResultCode.EnumItemName

I think you're correct the only way to do this is to modify the IDL yourself. 我认为你是对的,唯一的办法是自己修改IDL。 I can tell you a little about how it's done... 我可以告诉你一些关于它是如何完成的......

  1. You run tlbexp.exe to create the tlb from your C# assembly. 您运行tlbexp.exe以从C#程序集创建tlb。
  2. You run oleview.exe to open that tlb and inspect the IDL. 您运行oleview.exe打开该tlb并检查IDL。 You can save that IDL out to a file or copy/paste it. 您可以将该IDL保存到文件中或复制/粘贴它。
  3. You edit the IDL to give it the enum item names you want. 您编辑IDL以为其提供所需的枚举项目名称。
  4. You run midl.exe to generate a tlb from your modified IDL. 您运行midl.exe以从修改后的IDL生成tlb。

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. 对不起,我不能给你所有正确的命令行开关,但我现在不在Windows机器上。

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

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