[C++] LPCSTR Type을 LPOLESTR Type으로 변환

HRESULT __fastcall AnsiToUnicode(LPCSTR pszA, LPOLESTR* ppszW) { 
    ULONG cCharacters;
    DWORD dwError;

    // If input is null then just return the same.
    if (NULL == pszA)
    {
        *ppszW = NULL;
        return NOERROR;
    }

    // Determine number of wide characters to be allocated for the
    // Unicode string.
    cCharacters =  strlen(pszA)+1;

    // Use of the OLE allocator is required if the resultant Unicode
    // string will be passed to another COM component and if that
    // component will free it. Otherwise you can use your own allocator.
    *ppszW = (LPOLESTR) CoTaskMemAlloc(cCharacters*2);
    if (NULL == *ppszW)
        return E_OUTOFMEMORY;

    // Covert to Unicode.
    if (0 == MultiByteToWideChar(CP_ACP, 0, pszA, cCharacters,
                  *ppszW, cCharacters))
    {
        dwError = GetLastError();
        CoTaskMemFree(*ppszW);
        *ppszW = NULL;
        return HRESULT_FROM_WIN32(dwError);
    }

    return NOERROR;
}

SOAP, SOAP, SOAP, SOAP.. 지금 내 머리속엔 비누방울이 아른 아른~ 아침 출근할때 감기 바이러스가 몸에 침투를 했나부다. 몸에 열… 점심때 후식으로 먹은 빵이 불량식품이였나부다. 속이 부글부글.. 뼈를 싹인다는 Coco Cola로 일단 속을 달래는 중….

으.. 아까 콜라 사러 1층 편의점에 가려고 엘리베이터타려고 기다리는데 (사무실은 11층).. 이 놈의 건물의 엘리베이터의 움직이는 속도가 정말 장난이 아니다.. 가끔 엘리베이터를 기다리는 건지… 한없이 감감 무소식으로 오지 않는 지하철을 기다리는건지….. 성질 급한 사람은 가끔 화가 날 법도 하다.. 나같이 오늘처럼 말이다..

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다