char型をマルチバイト文字列に変換する。
HRESULT Cxxxx::DXconvAnsiToWide( WCHAR* wstrDest, const CHAR* strSrc, int ct )
{
// 引数の*がNULLの場合と、文字数が1以下の場合はエラー
if( wstrDest==NULL || strSrc==NULL || ct < 1 )
return E_INVALIDARG;
int nResult = MultiByteToWideChar( CP_ACP, 0, strSrc, -1, wstrDest, ct );
wstrDest[ct-1] = 0;
if( nResult == 0 )
return E_FAIL;
return S_OK;
}
HRESULT Cxxxx::DXconvAnsiToWide( WCHAR* wstrDest, const CHAR* strSrc, int ct )
{
// 引数の*がNULLの場合と、文字数が1以下の場合はエラー
if( wstrDest==NULL || strSrc==NULL || ct < 1 )
return E_INVALIDARG;
int nResult = MultiByteToWideChar( CP_ACP, 0, strSrc, -1, wstrDest, ct );
wstrDest[ct-1] = 0;
if( nResult == 0 )
return E_FAIL;
return S_OK;
}
PR
この記事にコメントする