|
发表于 2003-10-31 12:25:00
|
显示全部楼层
哥们~具体点啊
看看这对你没帮助
BOOL CGame::InitializeDirectAudio(HWND hwnd)
{
LogInfo("<br>Initialize DirectAudio:");
//Create the DirectAudio performance object
if(CoCreateInstance(CLSID_DirectMusicPerformance,NULL,
CLSCTX_INPROC,IID_IDirectMusicPerformance8,
(void**)& m_pDirectAudioPerformance) != S_OK)
{
LogError("<li>Failed to create the DirectAudio performance object.");
return FALSE;
}
else
LogInfo("<li>DirectAudio performance object created OK.");
//Ceate the DirectAudio loader object.
if(CoCreateInstance(CLSID_DirectMusicLoader,NULL,CLSCTX_INPROC,
IID_IDirectMusicLoader8,(void**) &m_pDirectAudioLoader) != S_OK)
{
LogError("<li>Failed to create the DirectAudio loader object.");
return FALSE;
}
else
LogInfo("<li>DirectAudio loader object created OK.");
//Initialize the performance object.
if(FAILED(m_pDirectAudioPerformance->InitAudio(NULL,NULL,hwnd,DMUS_APATH_SHARED_STEREOPLUSREVERB,
64,DMUS_AUDIOF_ALL,NULL)))
{
LogError("<li>Failed to initialize the DirectAudio performance object.");
return FALSE;
}
else
LogInfo("<li>Initialised the DirectAudio performance object OK.");
//Get the applications "sounds" directory.
CHAR strSoundPath[MAX_PATH];
GetCurrentDirectory(MAX_PATH,strSoundPath);
strcat(strSoundPath,"\\Sounds");
//Convert the path to unicode.
WCHAR wstrSoundPath[MAX_PATH];
MultiByteToWideChar(CP_ACP,0,strSoundPath,-1,wstrSoundPath,MAX_PATH);
//Set the search directory.
if(FAILED(m_pDirectAudioLoader->SetSearchDirectory(GUID_DirectMusicAllTypes,
wstrSoundPath,FALSE)))
{
LogError("<li>Failed to set the search directory '%s'.",strSoundPath);
return FALSE;
}
else
LogInfo("<li>Search directory '%s' set OK.",strSoundPath);
return TRUE;
} |
|