T2stdstring

int T2stdstring(TCHAR* szString,std::string& str)

{

 

#ifdef _UNICODE

 

    int len=lstrlen(szString)*2;

    char * p=new char[len+1];

    if(!p)

       return -1;

 

    memset(p,0,len+1);

      

    WideCharToMultiByte (CP_ACP, 0, szString, -1, p, len, NULL,NULL);

 

    str=p;

 

    delete p;

 

#else

 

    str=szString;

#endif

 

    return 0;

 

}

posted on 2010-05-01 21:43  devcfei  阅读(124)  评论(0编辑  收藏  举报