如何将 System::IO::Stream^ 转换为 PlaySound 的 LPCSTR?
我正在尝试在 C++/CLI 应用程序中嵌入然后播放 .wav 文件,但我见过的所有使用 PlaySound
的示例都是在 VB 中进行的。我不知道如何从 Stream^
到 PlaySound 所需的 LPCSTR:
System::IO::Stream^ s = Assembly::GetExecutingAssembly()->GetManifestResourceStream ("Ping.wav");
LPCSTR buf = s->????;
PlaySound(buf, NULL, SND_ASYNC|SND_MEMORY|SND_NOWAIT);
我想我需要某种可怕的 .net 内存转换魔法。
I'm trying to embed and then play back a .wav file in a C++/CLI app but all the examples I've seen which use PlaySound
are in VB. I can't see how to get froma Stream^
to the LPCSTR which PlaySound requires:
System::IO::Stream^ s = Assembly::GetExecutingAssembly()->GetManifestResourceStream ("Ping.wav");
LPCSTR buf = s->????;
PlaySound(buf, NULL, SND_ASYNC|SND_MEMORY|SND_NOWAIT);
I guess I need some sort of horrible .net memory conversion magic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请改用 System::Media::SoundPlayer 类。它有一个 Stream 属性,将“s”变量分配给它,然后调用 Play() 方法。
Use the System::Media::SoundPlayer class instead. It has a Stream property, assign your "s" variable to it, then call the Play() method.