我正在使用 Visual Studio 2010 express,我正在尝试编写一个简单的程序,该程序将重复波形文件 5 次(我正在运行 Windows xp sp3).
这是我得到的:
#include "stdafx.h"#include #include 使用命名空间标准;int主(){int a = 5;而(a >= 1){cout<<"这是一个 wav 文件";PlaySound(L"SomeAudioFile-01.wav", NULL, SND_FILENAME);- 一种;}返回0;}问题是我在构建它时不断收到此错误消息:
1>------ Build开始:项目:这是一个F**king国家,配置:发布Win32 - ----1> mycode.cpp1>..\..\..\..\..\Shaul's documents\Visual Studio 2010\Projects\MyProject\Release\SomeAudioFile-01.wav:致命错误 LNK1136:文件无效或损坏========== 构建:0 成功,1 失败,0 最新,0 跳过 ==========该文件非常好,在 Visual Studio 之外播放没有任何问题.
非常感谢您的帮助.
解决方案不是将 WAV 文件添加到项目文件中,而是将其添加到资源中并使用 SND_RESOURCE而不是 SND_FILENAME.
I'm using visual studio 2010 express and I'm trying to write a simple program that will repeat a wave file 5 times(I'm running a windows xp sp3).
This is as far as I got:
#include "stdafx.h" #include <windows.h> #include <iostream> using namespace std; int main () { int a = 5; while(a >= 1){ cout << "It's a wav file"; PlaySound(L"SomeAudioFile-01.wav", NULL, SND_FILENAME); --a; } return 0; }The problem is I keep getting this error message when I'm building it:
1>------ Build started: Project: It's a F**king Country, Configuration: Release Win32 -- ---- 1> mycode.cpp 1>..\..\..\..\..\Shaul's documents\Visual Studio 2010\Projects\MyProject\Release\SomeAudioFile-01.wav : fatal error LNK1136: invalid or corrupt file ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========The file is perfectly fine and plays with no problems whatsoever outside visual studio.
Help would be truly appreciated.
解决方案Instead of adding the WAV file to the project files, add it to the resources and use SND_RESOURCE instead of SND_FILENAME.
更多推荐
播放 .wav 文件
发布评论