我想在我的程序中添加函数以在Qt中关闭显示器。我从互联网上添加了这个流行的Winapi代码:
void MainWindow::on_Start_TurnOffMonitor_clicked()
{
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);
}
但在编译时我发现了错误:
mainwindow.obj:-1:错误:LNK2019:未解析的外部符号__imp__SendMessageW @ 16在函数“private:void __thiscall MainWindow :: on_Start_TurnOffMonitor_clicked(void)”中引用(?on_Start_TurnOffMonitor_clicked @ MainWindow @@ AAEXXZ)
我该如何解决?