我如何在COM/ATL DLL中添加函数并在C#中使用它 [英] How i add a function in COM/ATL DLL and use it in C#

查看:51
本文介绍了我如何在COM/ATL DLL中添加函数并在C#中使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我真的很感谢您在以下内容中提及的任何人:
http://www.codeproject.com/KB/atl/SimpleATLComWithDotNet.aspx

但是在本教程中,只提到了将方法添加到COM/ATL DLL中并在C#中使用它....,而没有提及添加功能.

我试图添加一个功能,但未成功.您能否告诉我将功能添加到COM/ATL DLL中并可以在C#中使用它的方法.

如果您不介意,请给我举个简单的例子.

谢谢大家

@Samer Abu Rabie:谢谢即时阅读
@Christian Graus:我不想给出有关函数或方法的概念,但是在我的情况下,我在同一个类中编写了一个方法和一个函数,我将其构建到DLL中并在C#中使用.但是当我使用此类时,C#只能识别方法而不是功能.

@Christian Graus:通过本教程,我刚刚学习了COM/ATL DLL:用于编写简单COM/ATL DLL的入门教程并将其与.NET一起使用 [ ^ ]
这就是我所有的知识.

这是我的示例代码: http://www.mediafire.com/?wgmzmjoyxyk [

Hi all,

I realy thanks for guy about anything mention in:
http://www.codeproject.com/KB/atl/SimpleATLComWithDotNet.aspx

But in this tutorial just mention about adding METHODS into COM/ATL DLL and use it in C#....and didnt mention about adding FUNCTIONS.

i tried to add a FUNCTION but unsuccessfully. Can you tell me the way to adding FUNCTIONS into COM/ATL DLL and can use it in C#.

if you dont mind, give me a brief example.

thanks all

@Samer Abu Rabie: thanks im reading it now
@Christian Graus: i dont want to give concept about Function or Method, but in my situation i write a method and a function in same class, i build it into DLL and use in C#. But when i use this class C# just recognize the method and not function.

@Christian Graus:I have just learnt COM/ATL DLL though this Tutorial:A Beginner Tutorial for Writing Simple COM/ATL DLL and Using it with .NET [^]
and that''s all my knowledge about it.

Here my sample code: http://www.mediafire.com/?wgmzmjoyxyk[^]
solution ATL_SimpleSample: create ATL DLL file, my function and method in math2 class(math2.cpp)
solution CallATL: to use DLL file,please see program.cs file. i can use Multi method, but MultiReturn function.

推荐答案

下面是有关如何在C#中调用非托管dll的链接,希望对您有所帮助:
http://msdn.microsoft.com/en-us/magazine/cc301501.aspx [ ^ ]
Well here is a link on how to to call unmanaged dlls in C#, hope this helps:
http://msdn.microsoft.com/en-us/magazine/cc301501.aspx[^]


添加方法(函数是同一件事,对不起,我不知道您在说什么),只要它在COM接口上公开,就可以导入它并叫它.我不知道p/invoke是否可以与COM dll中的dll方法一起使用.如果您对方法和函数的区别有所了解,那么您可能错了,但是您应该编辑您的文章以解释您的意思,以便我们回答您.
When you add a method ( a function is the same thing, sorry, I have no idea what you''re talking about ), so long as it''s exposed on the COM interface, you can import it and call it. I don''t know if p/invoke works with dll methods in a COM dll. If you have some concept of how a method and a function are different, you''re probably wrong, but you should edit your post to explain what you mean, so we can answer you.


silva103写道:
silva103 wrote:

@Christian Graus:我不想提供有关Function或Method的概念,但是在我的情况下,我编写了一个method和一个Function在同一个类中,我将其构建到DLL中并在C#中使用.但是当我使用此类时,C#只能识别方法而不是功能.

@Christian Graus: i dont want to give concept about Function or Method, but in my situation i write a method and a function in same class, i build it into DLL and use in C#. But when i use this class C# just recognize the method and not function.




很抱歉,但是作为开发人员有10年的经验,包括相当一段时间的COM使用经验,除了您可能认为它没有出现在界面中(这是错误的)之外,我还可能不知道你在说什么.

就像我说的那样,我不确定COM dll是否可以通过p/invoke调用其接口上没有的方法,这肯定是其他人链接到的.




I''m sorry, but 10 years of experience as a developer, including quite some time with COM, and apart from the possibility that you think it''s a function if it does not appear in the interface ( which is false ), I have no idea what the hell you''re talking about.

Like I said, I am not sure that a COM dll can have the methods not on it''s interface called via p/invoke, which is surely what the other guy linked to.


这篇关于我如何在COM/ATL DLL中添加函数并在C#中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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