在C#中使用c lib文件 [英] use of c lib file in c#

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

问题描述

大家好

我想在C#中使用c lib文件.我只有lib文件,我不知道在创建lib文件时使用了什么函数变量等.

1是否可能在c#中使用c未知的lib文件?
2是因为我不知道lib文件内部的功能而在c#中使用它是可能的.


关于

Hi All

i want to use c lib file in C#. i have only the lib file i dont know whats the function variables etc used in creating the lib file

1 Is it possibel that c unknown lib file used in c#?
2 Is it possibel that i dont know functionality inside the lib file and i use in c#.


Regards

推荐答案

1)可以通过使用DllImport在c#中调用C库. 2)无法调用您不了解的东西.

通常不建议新手程序员从事这种互操作性,因为这非常困难并且需要对调用双方(C和C#)都具有广泛的了解.

您需要解决的事情是参数打包,字符串转换,内存分配和释放等.

检查以下链接:
http://en.allexperts.com/q/C-3307/2008/2/Using-C-class-C.htm?rd = 1 [ http://social.msdn.microsoft.com /forums/zh-CN/vcgeneral/thread/299da822-5539-4e5b-9ba7-b614e564c9f4/ [
1) It is possible to call C libraries in c# through the use of DllImport.
2) It is not possible to call something which you have no knowledge of.

Generally it is not advised for novice programmers to embark in this kind of interoperability as it is very hard and requires extensive knowledge of both sides of the call (C and C#).

Things you have to work around are parameter packing, string conversions, memory allocation and freeing etc.

Check the following links :
http://en.allexperts.com/q/C-3307/2008/2/Using-C-class-C.htm?rd=1[^]

http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/299da822-5539-4e5b-9ba7-b614e564c9f4/[^]


这篇关于在C#中使用c lib文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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