vb中的dll使用的低级问题(自制dll并关于加密),盼速回复
今日我在做一个项目时遇到了问题 。我在vc中写好了dll,然后想在vb中来使用,可是遇到了很多问题。诚请各位指教:
//////////////////////////////////////////////////////////////
在md5dll.h中
#ifdef MD5DLL_EXPORTS
#define MD5DLL_API __declspec(dllexport)
#else
#define MD5DLL_API __declspec(dllimport)
#endif
(后来我干脆改到了#define MD5DLL_API __declspec(dllexport))
//////////////////////////////////////////////////////////////
在md5dll.cpp中
void MD5DLL_API MD5_Block (WORD key, WORD flag, BYTE *string , WORD len, MD5_Context *state, BYTE result[16])
其中:
word-->double byte
byte-->unsigned char
md5_context--->user defined data type ,as follows:
typedef struct {
UINT4 state[4];
UINT4 count[2];
BYTE buffer[64];
} md5-context;
其中在头文件中:typedef unsigned long int UINT4;
typedef unsigned char BYTE
//////////////////////////////////////////////////////////////
在.bas中:
Public Declare Sub ExploitMD5 Lib "md5dll" (ByVal key As Integer, ByVal flag As Integer, m_string As String, ByVal m_len As Integer, state As md5_context, result as String)
(我已经将md5dll.dll文件copy到了我的windows\system目录下面)
(我的用意是:用key参数传一个key密钥,用flag参数传一个const型的flag变量,用m_string参数传要加密的字符串指针,用m_len参数传一个字符串的长度值,用state参数传一个md5_context的上下文,并用result参数传一个字符串指针)
其中自定义的类型是:
Public Type md5_context
state(4) As Long
count(4) As Long
buffer(64) As Byte
End Type
/////////////////////////////////////////////////////////////
在测试时,我在.frm中:
//常量定义
Const sblock As Byte = 1
Const fblock As Byte = 2
Const mblock As Byte = 3
Const lblock As Byte = 4
//变量定义
Dim p_md5Key As Integer
Dim p_BlockFlag As Byte
Dim p_SourceString(1024) As BYTE
Dim p_SourceStringLen As Integer
Dim p_md5context As md5_context
Dim p_md5Result(16) As Byte
//变量初始化
p_md5Key = 123
p_BlockFlag = sblock
p_SourceString = "testofmd5"
p_SourceStringLen = LenB(p_SourceString)
//测试函数功能
ExploitMD5(byval p_md5Key,byval p_BlockFlag,byval p_SourceString,byval p_SourceStringLen, byref p_md5context, byref p_md5Result)
这时候总是出现语法错误的警告,十分痛苦。
///////////////////////
附: 如果在这里我还有没有写清楚的地方,请您一定来问我而不要花时间猜测。我的呼机是68154499呼202771,email是wenchuyuan@263.net。谢谢各位的鼎力帮助!!!!