Windows7.1 SDK: C2373: "MonitorFromWindow" 重新定义

Windows7.1 SDK: C2373: "MonitorFromWindow" Redefinition

32 位版本 VS10 MCBS 中的错误 "linkage specification is incompatible with previous "MonitorFromWindow"" 是针对以下声明给出的:

 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
    HMONITOR MonitorFromWindow(_In_ HWND  hwnd, _In_ DWORD dwFlags);

    return DialogBoxW(hInstance, MAKEINTRESOURCEW(lpTemplate), nullptr, DlgProc);
}

假设解决方案与给定的解决方案类似 here,但这里可能是 SDK 的一些问题,尽管首选某种 header hack。

错误告诉您您的 MonitorFromWindow 声明与之前的声明冲突。 Winuser.h 中的先前声明声明了具有 extern "C" 链接的函数,是 __declspec(dllimport) 并且具有 __stdcall 调用约定。

您应该删除错误的声明并使用头文件中的声明。