Link to home
Start Free TrialLog in
Avatar of JonMny
JonMny

asked on

Is there a macro or an easy way to search an LPCTSTR for a string

I am calling a function that returns a LPCTSTR. I need to search the LPCTSTR for a value. Essentially I need a "Contains" function. Is there a marco that already exists that can do this?  If not how can I convert to std::string?

CString is not an option.
SOLUTION
Avatar of js-profi
js-profi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of js-profi
js-profi

a typo and forgot delete the memory after use

        size_t l = wcslen(lp);
        char * szb = new char(2 * l +1); // some extra buff
        wcstombs(szb, lp, 2*l + 1);
        s = szb;   // assign after converting multi-byte to wide strings

        delete [] szb;