int i,n,m;    
char m_strTemp[m];
SAFEARRAY FAR* bLogonPw;
SAFEARRAYBOUND rgsabound[n]; //n*m
             for (i=0;i<n;i++) {
rgsabound[i].lLbound = 0;
     rgsabound[i].cElements = sizeof(char)*m ; bLogonPw = SafeArrayCreate(VT_UI1, n, rgsabound); long lLBound = (m_tParam.m_BizPara.bLogonPw)->rgsabound[i].lLbound; for(long l = lLBound; l < m; l++)
{
SafeArrayPutElement(.bLogonPw, &l, &m_strTemp[l]);
}
...
}

解决方案 »

  1.   

    int i,n,m;    
    char m_strTemp[m];
    SAFEARRAY FAR* bLogonPw;
    SAFEARRAYBOUND rgsabound[n]; //n*mfor (i=0;i<n;i++){
       rgsabound[i].lLbound = 0;
       rgsabound[i].cElements = sizeof(char)*m ;
       bLogonPw = SafeArrayCreate(VT_UI1, n, rgsabound);
       long lLBound = (m_tParam.m_BizPara.bLogonPw)->rgsabound [i].lLbound;
       for(long l = lLBound; l < m; l++)
       {
          SafeArrayPutElement(bLogonPw, &l, &m_strTemp[l]);
        }
    ...
    }
      

  2.   

    bLogonPw = SafeArrayCreate(VT_UI1, n, rgsabound);//不会将上一次分配的数组指针覆盖掉吗
    m_tParam.m_BizPara.bLogonPw//这个对象怎么没有定义
      

  3.   

    Sorry for too late to reply you. int i,n,m;    
    char m_strTemp[m];
    SAFEARRAY FAR* bLogonPw;
    SAFEARRAYBOUND rgsabound[n]; //n*mbLogonPw = SafeArrayCreate(VT_UI1, n, rgsabound);for (i=0;i<n;i++){
       rgsabound[i].lLbound = 0;
       rgsabound[i].cElements = sizeof(char)*m ;
       //bLogonPw = SafeArrayCreate(VT_UI1, n, rgsabound);
       //long lLBound = (m_tParam.m_BizPara.bLogonPw)-rgsabound.lLbound;
       long lLBound = bLogonPw->rgsabound[i].lLbound;
       for(long l = lLBound; l < m; l++)
       {
          SafeArrayPutElement(bLogonPw[i], &l, &m_strTemp[l]);
        }
    ...
    }have a try pls, I don't have VC in my machine now .tell me if there
    is still any error.
     
      

  4.   

    谢谢了哥们儿,我已经回用safearray操作多维数组了,   
    SafeArrayPutElement(bLogonPw[i], &l, &m_strTemp[l]);没试过可能有点问题
    其实关键是将&l改为Long L[2]={n,m};再用&l传入,就可以操作第n,m个元素了
    其它没什么花活,我现在不明白的是怎样将这样一个n*m的数组传给vb用而不必告诉它数组的具体参数。