void __stdcall A2B(char *pString, int StrNum)
{
int i;
//把所有A字符的转化为B字符
for (i=0; i<StrNum; i++)
{
if (pString[i] == 'A') pString[i] = 'B';
}}
在VC的导出函数定义文件中mydll.def中已经定义
EXPORTS
GetNum
A2B因为这里的GetNum使用得很好,所以A2B应该也是导出了的。
------------
VB中:
Private Declare Function A2B Lib "Mydll.dll" (ByVal pString As String, StrNum As Long)Private Sub Command3_Click()
Dim strSource As String
strSource = "AACCAA"
A2B strSource, Len(strSrouce)
Me.AutoRedraw = True
Print strSource '如果正确应该输出的是BBCCBB
End Sub---------------一点这个按钮,就内存不能读,非法操作,退出了。各位大哥,请教了!!!我这里也没有感觉到数组越界啊。怎么回事呢?
A2B byval strSource, 6试下。
len1=Len(strSource)
A2B strSource, len1
这样就没有问题了,不知道是什么原因