如何解决C++ WindowsApp LNK2028Error
当我在 Visual Studio 2019 中编译以下代码时,我收到以下错误代码:code of the error output。这似乎是一个 LNK2028 错误,但我不明白发生了什么。有人可以解释为什么我会收到此错误吗?
这是我的代码:
#include "MyForm.h"
#include <windows.h>
#include <windowsx.h>
#include <winuser.h>
#include <tchar.h>
using namespace System;
using namespace System::Windows::Forms;
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LParaM lParam)
{
HWND p = findwindowex(hwnd,NULL,_T("SHELLDLL_DefView"),false);
HWND* ret = (HWND*)lParam;
if (p) {
// Gets the WorkerW Window after the current one.
*ret = findwindowex(NULL,hwnd,_T("WorkerW"),NULL);
}
return true;
}
HWND get_wallpaper_window()
{
// Fetch the Progman window
HWND progman = FindWindow(_T("ProgMan"),NULL);
// Send 0x052C to Progman. This message directs Progman to spawn a
// WorkerW behind the desktop icons. If it is already there,nothing
// happens.
SendMessageTimeout(progman,0x052C,SMTO_norMAL,1000,NULL);
// We enumerate all Windows,until we find one,that has the SHELLDLL_DefView
// as a child.
// If we found that window,we take its next sibling and assign it to workerw.
HWND wallpaper_hwnd = NULL;
EnumWindows(EnumWindowsProc,(LParaM)&wallpaper_hwnd);
// Return the handle you're looking for.
return wallpaper_hwnd;
}
[STAThread]
void main(array<String^>^ args)
{
Application::EnableVisualStyles;
Application::SetCompatibleTextRenderingDefault(false);
DEM0::MyForm form;
Application::Run(% form);
}
解决方法
正如在 this 和 this 帖子中提到的,问题似乎是由于链接器错误引起的(我相信 8 个函数调用)依赖于 {{ 1}} 位于 User32.dll
more info about this。
在当前的项目中,您似乎缺少包含其他依赖项。您可以通过转到项目属性 -> 链接器 -> 输入 -> 附加依赖项来包含这些文件。在这里您可以选择包含 C:\windows\system32
文件或选择 User32.dll
选项。我相信这会解决您的链接器错误。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。