SetSuspendState在c中给出链接错误 [英] SetSuspendState Gives the Linking error in c
问题描述
我的程序是尝试将系统置于待机模式.
Hi,
My program is try to put system in standby mode.
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <PowrProf.h>
int main(int argc, char* argv[])
{
SetSuspendState(TRUE, FALSE, FALSE);
return 0;
}
我包含了库文件"PowrProf.lib"
.
即使出现两个链接错误.
错误是:
stanby.obj:错误LNK2001:无法解析的外部符号"unsigned char __stdcall SetSuspendState(unsigned char,unsigned char,unsigned char)"(?SetSuspendState @@ YGEEEE @ Z)
Debug/stanby.exe:致命错误LNK1120:1个未解决的外部组件
执行link.exe时出错.
I Include the library file "PowrProf.lib"
.
Even though it gives two linking errors.
Error is:
stanby.obj : error LNK2001: unresolved external symbol "unsigned char __stdcall SetSuspendState(unsigned char,unsigned char,unsigned char)" (?SetSuspendState@@YGEEEE@Z)
Debug/stanby.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
What is the solution for this.
推荐答案
您在哪里包括PowrProf.lib
?检查它是否正确包含在项目的链接器属性中.
Where did you include PowrProf.lib
? Check that it is correctly included in your project''s Linker properties.
您可能将库添加到了错误的位置,最简单的方法是在代码中包含库.
在#include
之后添加#pragma comment(lib, "PowrProf.lib")
行.
这仅适用于Visual Studio编译器
You probably added the library into the wrong place, simplest way of including a library is in the code.
Add the line#pragma comment(lib, "PowrProf.lib")
just after the#include
s.
This will only work on the Visual Studio Compiler
这篇关于SetSuspendState在c中给出链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!