从c ++ dll中提取函数信息 [英] Extract function information from c++ dll

查看:505
本文介绍了从c ++ dll中提取函数信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有c ++ DLL和1程序(不是代码),该程序从DLL调用1个函数,我只知道该函数的名称,现在都想从我的应用程序(C#)调用该函数。有可能吗?



谢谢

解决方案

我假设你只有DLL本身,如果你有一个头文件,这将会更容易,因为你可以直接跳过来找出如何PInvoke它。



首先你必须掌握函数签名,所以你知道参数和它们的类型。如果它是一个C ++ DLL,您可能可以通过 Dependency Walker 获取此信息,如果它是C DLL,您可能需要查看实际的汇编代码来计算参数及其类型。



如果您确定了签名,则可以使用PInvoke调用它来自C#,查看PInvoke 网站了解更多详细信息和许多示例。


i have c++ DLL and 1 program (not code) , that program calls 1 function from DLL, i know only name of that function, now all want to call that function from my application(C#). Is it possible?

Thanks

解决方案

I'm assuming that you only have the DLL by itself, if you've got a header file as well it would be much easier since you can skip straight to figuring out how to PInvoke it.

First you have to get hold of the function signature so you know the arguments and their types. If it's a C++ DLL you might be able to get this out with Dependency Walker, if it's a C DLL, you might have to look at the actual assembly code to figure out the arguments and their types.

If you do figure out the signature, then you can use PInvoke to call it from C#, look at the PInvoke website for more details and many samples.

这篇关于从c ++ dll中提取函数信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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