C++ LPCTSTR to char*

前端 未结 3 1159
隐瞒了意图╮
隐瞒了意图╮ 2021-01-25 14:56

I am using visual studio 2010 MFC to build a C++ program. My program calls a DLL that is not apart of the project and it accepts a char*. I have a function that gets a string in

3条回答
  •  时光取名叫无心
    2021-01-25 15:34

    LPCTSTR patientName= L"";
    CStringA sB(patientName);
    const char* pszC = sB; 
    
    DcmFileFormat fileformat;
    //Type casting below to const char * str
    OFCondition status = fileformat.loadFile(((LPCSTR)(CStringA)str));
    if (status.good())
    {
        if (fileformat.getDataset()->findAndGetString(DCM_PatientName, pszC).good())             
        {
            //Type casting from const char * to LPCTSTR
            m_List.InsertColumn(4, LPCTSTR(pszC) , LVCFMT_LEFT, 100); 
        }
     }
    

    This was the way i used to typecast the variables

提交回复
热议问题