3

我写了一个小应用程序让电脑进入待机模式:

#include "stdafx.h"
#include <windows.h>
#include <PowrProf.h>

int _tmain(int argc, _TCHAR* argv[])
{
   SetSuspendState(FALSE, FALSE, FALSE);

   return 0;
}

我收到此错误: 1>Standby.obj : 错误 LNK2001: 无法解析的外部符号 _SetSuspendState@12 1>C:\Documents and Settings\Sobak\Desktop\Standby\Release\Standby.exe : 致命错误 LNK1120: 1 unresolved externalsexternals

我该如何解决?

PS我使用Visual Studio 2005

先感谢您。

4

1 回答 1

5

您应该将您的程序与PowrProf.lib库链接。您可以通过添加以下字符串来做到这一点:

#pragma comment(lib, "PowrProf.lib")
于 2010-07-21T19:55:26.117 回答