gpt4 book ai didi

c++ - 需要帮助使用 C++ DirectX/XAML 加载 Cortana VCD 文件

转载 作者:太空宇宙 更新时间:2023-11-04 13:30:18 24 4
gpt4 key购买 nike

我正在将 Cortana 添加到 DirectX/XAML Windwos 10 游戏中。我能找到的每个示例都是用 C# 而非 C++ 给出的。通常这不是问题,但显然我没有在 C++ 中正确实现它,需要一些帮助。

这段代码的目的是加载一个 VCD 文件,Cortana 将其用于我与应用程序相关的语音命令。我已经使用标准示例创建了 VCD 文件。

这是我在 C++ 中实现时遇到问题的特定 C# 代码:

var storageFile = 
await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(
new Uri("ms-appx:///myvcdfile.xml"));
await
Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.
InstallCommandDefinitionFromStorageFileAsync(storageFile);

我尝试的 C++ 实现是:

Uri^ uri = ref new Uri("ms-appx:///myvcdfile.xml");
create_task(StorageFile::GetFileFromApplicationUriAsync(uri)).then([](task<StorageFile^> t) {
StorageFile^ sfile = t.get();
Windows::ApplicationModel::VoiceCommands::VoiceCommandDefinitionManager::InstallCommandDefinitionsFromStorageFileAsync(sfile);
});

当我运行它时,没有抛出可见的错误(没有立即崩溃)但在输出窗口中抛出了以下异常:

Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x40080201: WinRT originate error (parameters: 0x8000000B, 0x00000040, 0x018BE280).
Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x00000005: Access is denied.
Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x000006D9: There are no more endpoints available from the endpoint mapper.
Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x000006D9: There are no more endpoints available from the endpoint mapper.
Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x40080201: WinRT originate error (parameters: 0x80004005, 0x00000013, 0x0EEAF160).

“访问被拒绝”错误让我觉得打开文件本身存在一些问题,尽管如果我故意输入无效的文件名,这是一个完全不同的错误,它会崩溃,所以我知道它正在寻找文件,但也许有一些实际访问它有问题吗?

此外,即使我排除了“InstallCommandDefinitionsFromStorageFileAsync()”行,仍然会抛出异常。

感谢任何帮助,提前致谢!

最佳答案

您的 xml 文件中肯定有错误(例如,如果您使用 PhraseList 命令设置了一个项目,但您忘记了 xml 中的 PhraseList 节点)

关于c++ - 需要帮助使用 C++ DirectX/XAML 加载 Cortana VCD 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31750413/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com