游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2073|回复: 1

在Win98使用DirectAudio的问题

[复制链接]

69

主题

450

帖子

473

积分

中级会员

战魂缔造者

Rank: 3Rank: 3

积分
473
QQ
发表于 2003-10-30 21:57:00 | 显示全部楼层 |阅读模式
在Win98使用DirectAudio从带有中文的目录载入文件时
为什么会出错?
在WINXP DirectAudio和Win 98 Direct 7.0里不会出这样的错误
请问怎样解决?

35

主题

105

帖子

119

积分

注册会员

Rank: 2

积分
119
发表于 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;
}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-2-23 18:19

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表