这是DLL里的函数
WORD WJ1608Card_WriteBuy(int iVer,float dblWriteBuy,BYTE* _bWriteTime,BYTE*_bWriteCode)我想调用这个函数,但不知道怎么把CString的数据以BYTE*写进去
   float  buy =2.3f; 
   CTime m_StartTime2 = CTime::GetCurrentTime();
   CString cStartTime = m_StartTime2.Format( "%Y%m%d%H%M%S" );
   BYTE  a10[100],a20[100];
   我想把cStartTime的值赋给a10,应该怎么写?????
   st=WJ1608Card_WriteBuy(3,buy,a10,a20); 

解决方案 »

  1.   

    memcpy(a10, (LPCTSTR)m_StartTime2, m_StartTime2.GetLength());
      

  2.   

    memcpy(a10, cStartTime,12);这样不行时间是071213105021的话,它取的是
    303731323133
      

  3.   

    WORD   WJ1608Card_WriteBuy(int iVer, float dblWriteBuy, BYTE* _bWriteTime, BYTE* _bWriteCode)我对这个函数比较感兴趣,既然传进去的是BYTE*,怎么没有一个长度呢的?
    那么他怎么知道BYTE*的长度是多少呢?
      

  4.   

    >>我想把cStartTime的值赋给a10,应该怎么写????? 
    memset(a10, 0x0, sizeof(a10) );
    cStartTime="071213105021";
    memcpy(a10,   cStartTime,12);
    //这样不行时间是071213105021的话,它取的是
    //303731323133
    不知道楼主是怎么得出303731323133这个结果的。
      

  5.   

    float     buy   =2.3f;   
    CTime   m_StartTime2   =   CTime::GetCurrentTime(); 
    CString   cStartTime   =   m_StartTime2.Format("%Y%m%d%H%M%S"); 
    BYTE     a10[100],a20[100]; 
    memset(a10,0,100);
    memcpy(a10,(LPCSTR)cStartTime,cStartTime.GetLength());
    这样可以吧
      

  6.   

    BYTE  a10[100] = {0x07, 0x12,0x14, 0x12,0x12, 0x12};
    这样的话就可以把071214121212写进去了
      

  7.   

    (CONST BYTE* )((LPCTSTR) cStartTime)
      

  8.   

    int decstr2hexbyte( const char* str , BYTE * hexbyte)
    {
    int i, count;
    int nRet = 0; if ( str == NULL ) return nRet;
    count = (int)strlen(str);
    if (count == 0) return nRet; char stmp[5] = {0};
    strcpy(stmp,"0x");
    for (i=0; i<count; i+=2, nRet++)
    {
    stmp[2] = str[i];
    stmp[3] = str[i+1];
    hexbyte[nRet] = strtol(stmp, NULL, 0);
    } return nRet;
    }