LPCSTR to LPCWSTR converting

64 views Asked by At

I have created implemetation of converting LPCSTR to LPCWSTR

LPSTR W2S(LPCWSTR str)
{
    LPSTR strTo;
    char* szTo = (char*)HeapAlloc(GetProcessHeap(), 0, lstrlenW(str) + 1);
    szTo[lstrlenW(str)] = '\0';
    WideCharToMultiByte(CP_ACP, 0, str, -1, szTo, lstrlenW(str), NULL, NULL);
    strTo = szTo;
    HeapFree(GetProcessHeap(), NULL, szTo);
    return strTo;
}

But it doesn't work, what's the problem?

0

There are 0 answers