Original Post
Hi folks,
I''m trying to initialize a DirectMusic object, but I need to pass the executable''s directory as a WCHAR to the Loader->SetSearchDirectory function.
In a tutorial I saw the MultiByteToWideChar function that convertes CHAR to WCHAR, but when I use it, it only copies one character to the destination buffer.
Does anyone know why this happens?
The macro for the function is:
#define MULTI_TO_WIDE( x,y ) MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, y, -1, x, _MAX_PATH );
funtion()
{
char szDir[_MAX_PATH];
WCHAR wszDir[_MAX_PATH];
if(_getcwd( szDir, _MAX_PATH ) == NULL)
{
return NULL;
}
// at this point szDir = "D:\cpp\Direct3D tutorial 1"
// convert szDir to wszDir
MULTI_TO_WIDE(wszDir, szDir);
// wszDir = "D"
}
[/CODE]
I hope you folks can help me so I won''t have to make a ''dead'' game. If there is a better function than _getcwd to get the directory where the program executable resides (preferably as a WCHAR), I sure would like to hear about it too.
Dennis