C#怎么引用dll中的函数
code.dll中有一函数:
BOOL EncodePassword(CString password, CString &newpas) //加密password的内容,加密后的内容放在newpas里。
请问该函数在C#中怎么引用?
[解决办法]
首先把这个DLL文件放到(拷贝)你的BIN目录下,然后在要引用这个方法的类中添加using引用,引用包含这个方法的命名空间
比如你的DLL文件中是这样写的
- C# code
namespace test.md5{class MD5{//........}}
[解决办法]
[DllImport("动态库名称", EntryPoint = "函数名称", CallingConvention = CallingConvention.Cdecl)]
public static extern int 你自己定义的函数名(参数,参数要和dll中的一致)
还要加个这样的using:
using System.Runtime.InteropServices;