//Dll.h#ifdef BLOOMFILTER_API#else#define BLOOMFILTER_API extern "C" _declspec(dllimport)#endif#include<string>using namespace std;BLOOMFILTER_API int RSHash(string str, int nLen);//Dll.cpp/#include "stdafx.h"#define BLOOMFILTER_API extern "C"__declspec(dllexport)#include "VDDll.h"int RSHash(string str, int nLen) { int b = 378551; int a = 63689; int hash = 0; for( int i = 0; i < nLen; i++) { hash = hash*a+str[i]; a = a*b; } return (hash & 0x7FFFFFFF); }//在C#中调用 class testadd { [DllImport("VDDLL.dll", EntryPoint = @"RSHash", CharSet = CharSet.Ansi)] public static extern int RSHash(string str, int nLen); } static void Main(string[] args) { Console.WriteLine(testadd.RSHash("asd",3)); }
- 2 回答
- 0 关注
- 1113 浏览
添加回答
举报
0/150
提交
取消