Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

johnnyBravo

Using DXUtil_ConvertAnsiStringToWideCch()??

This topic is 5264 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi i need to use this function:
quote:
//----------------------------------------------------------------------------- // Name: DXUtil_ConvertAnsiStringToWideCch() // Desc: This is a UNICODE conversion utility to convert a CHAR string into a // WCHAR string. // cchDestChar is the size in TCHARs of wstrDestination. Be careful not to // pass in sizeof(strDest) //-----------------------------------------------------------------------------
HRESULT DXUtil_ConvertAnsiStringToWideCch( WCHAR* wstrDestination, const CHAR* strSource, 
                                     int cchDestChar )
{
    if( wstrDestination==NULL || strSource==NULL || cchDestChar < 1 )
        return E_INVALIDARG;

    int nResult = MultiByteToWideChar( CP_ACP, 0, strSource, -1, 
                                       wstrDestination, cchDestChar );
    wstrDestination[cchDestChar-1] = 0;
    
    if( nResult == 0 )
        return E_FAIL;
    return S_OK;
}
But i am unsure on what to put as the size this is what i have so far got. LPCWSTR wFilename; string filename="a.mp3"; DXUtil_ConvertAnsiStringToWideCch(&wFilename,&filename.c_str(),???); so yeah what do i put in the ??? thanks,

Share this post


Link to post
Share on other sites
Advertisement
is it not listed in the help files / MSDN?

I''ve got a beta release of the SDK, so my docs aint perfect but I''ve been fairly happy with the SDK helpfiles before - they usually give a good idea of what each param is for.

hth
Jack

Share this post


Link to post
Share on other sites
i couldnt find anything on my msdn cds,

now ive got another problem where it keeps crashing

LPWSTR wFilename;
string filename="a.mp3";
DXUtil_ConvertAnsiStringToWideCch(&wFilename,&filename.c_str(),MAX_PATH);


when i call this, it just gets an access violation and crashes.

What could be wrong with that?
THanks,

[edited by - johnnyBravo on April 20, 2004 5:31:30 AM]

Share this post


Link to post
Share on other sites
As said in the other thread, use a WCHAR array, not a single WCHAR pointer.


WCHAR wFilename[260];

DXUtil_ConvertAnsiStringToWideCch(wFilename, filename.c_str(), 260);


And remove the & in front of filename.c_str().

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!