c++ - 无法编译旧的 WIN32 WINAPI 程序

标签 c++ winapi win64

我尝试了 CodeBlocks 和 MS VC++ 2010,但都无法编译。

他们在 中找不到 PlaySound() 的定义。 问题是什么?

case WM_CREATE:
    PlaySound (TEXT("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
    return 0 ;

错误:

error C2065: 'SND_FILENAME': nichtdeklarierter Bezeichner
error C2065: 'SND_ASYNC': nichtdeklarierter Bezeichner
error C3861: "PlaySound": Bezeichner wurde nicht gefunden.

windows.h 包含在 stdafx.h 中 但即使我将它直接包含在代码块中,它也不起作用。

最佳答案

PlaySound 的符号和SND_…mmsystem.h 中声明 header 并在 winmm.lib 中定义图书馆。您必须包含并链接这些内容。

关于c++ - 无法编译旧的 WIN32 WINAPI 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60865928/

相关文章:

c++ - 如何使用 ifdef 检测是否支持 Windows DWORD_PTR 类型?

windows - 适用于 Windows 64 位的 LVITEM

c++ - 使用函数 IsWin2000() 会产生 C++ 警告 : C4996 - Deprecated Function

c# - 从 Dll 导出接口(interface)。 C# Delphi VB C++ 等

linux - Linux pthread 中 SetThreadIdealProcessor 的替换

c++ - 显示矩阵 opencv 的奇怪行为

python - Windows 7 x64 上的 PyPy?

c++ - 计算组合时溢出

c++ - spdlog 错误 : "don' t know how to format the type, 包括 fmt/ostream.h(如果它提供了应使用的运算符 <<)”

c++ - 是否有一种通用方法来迭代一组对象中的特定变量?