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---------------一点这个按钮,就内存不能读,非法操作,退出了。各位大哥,请教了!!!我这里也没有感觉到数组越界啊。怎么回事呢?

解决方案 »

  1.   

    Private Declare Function A2B Lib "Mydll.dll" (ByVal pString As String, ByVal StrNum As Long)忘记了第二个参数也是按值传梯的。不过这样修改过以后还是错误的啦怎么搞呢???
      

  2.   

    Private Declare Function A2B Lib "Mydll.dll" (pString As String,byval StrNum As Long)'调用时
    A2B byval strSource, 6试下。
      

  3.   

    大哥,还是错误怎么会这样,谁能给我一个使用char*指针类型为参数的DLL程序例子看看啊???谢谢了。给我留言就可以了。
      

  4.   

    问题解决了!!A2B strSource, Len(strSrouce)这一句的问题不是在strSource,而是在Len(strSource)。只要:
    len1=Len(strSource)
    A2B strSource, len1
    这样就没有问题了,不知道是什么原因