旧的VB6 ActiveX EXE到C# [英] Old VB6 ActiveX EXE to C#

查看:104
本文介绍了旧的VB6 ActiveX EXE到C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在转换使用2个ActiveX EXE的旧桌面应用程序。它使用CreateObject()返回对COM对象的引用。然后使用此引用将相关信息传递给COM组件,例如数据库连接信息,并调用相应的函数。在IE中没有必要使用它。它仅用于此桌面应用程序。



使用C#在.Net中执行此操作的方法是什么。

I am converting an old desktop application that uses 2 ActiveX EXE''s. It uses CreateObject() to return a reference to the COM object. This reference is then used to pass in pertinent information to the COM component such as database connection information and call the appropriate fuctions. There is no need to use this in IE. It is only used from this desktop app.

What would be a way to do this in .Net using C#.

推荐答案

右键单击引用,添加引用

在对话框中选择COM选项卡并找到你的activeX对象 - 我现在会调用我的objA - 并点击确定。 objA应该出现在你的参考文献列表中。



在你的代码中你需要把

Right click References, Add Reference
select the COM tab in the dialog box and locate your activeX object - I''ll call mine objA for now - and hit Ok. objA should appear in your list of references.

In your code you will need to put
using objA;





然后你可以像任何其他对象一样使用它,例如< br $> b $ b



Then you can use it like any other object e.g.

objA a = new objA();
Debug.Print(objA.aMember.ToString());





在构建项目时,您将获得额外的文件名为Interop.objA.dll,需要与你的exe文件位于同一文件夹中。


我已经成功地将这种方法与几个传统的VB6 COM DLL一起使用了EXE - 但对任何拼写错误道歉!



When you build your project you will get an additional file called Interop.objA.dll which will need to live in the same folder as your exe

I''ve successfully used this approach with several legacy VB6 COM DLLs and EXEs - but apologies for any typos!


这篇关于旧的VB6 ActiveX EXE到C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆