在调用方法方面需要帮助 [英] need help with calling method

查看:80
本文介绍了在调用方法方面需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次做服务器和客户端应用程序,需要我从c#客户端调用c ++方法.我到底该怎么做?请显示有关此问题的一些示例代码,谢谢. ;-)

this is my first time doing a server and client application that need me to call a c++ method from a c# client. how exactly can i do it? Please show some sample code regarding this matter thank you. ;-)

推荐答案

如果它具有托管包装,则可以将其添加为对c#项目的引用.然后创建一个对象并使用它.

如果没有它,则使用DllImport属性.

如果您的C ++ dll使用序数或外部"C"导出方法,则您可以使用Win32 API来调用这些方法.
If it has a managed wrapper, then you can add it as reference to your c# project. Then create an object and use it.

If it does not have it, then use DllImport attribute.

If your C++ dll uses ordinal numbers or extern "C" to export methods, then you can use Win32 APIs to call the methods.


如果C ++代码是COM-Callable的,则只需添加对该DLL的引用.基本上,它将为您创建typelib.我相信(但不确定),该命名空间已成为dll库名称.
If the C++ code is COM-Callable, then you just need to add a reference to the DLL. It basically creates the typelib for you. I believe (but I''m not sure) that the namespace becomes the dll library name.


这篇关于在调用方法方面需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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