Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

My program is try to put system in standby mode.
C++
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <PowrProf.h>

int main(int argc, char* argv[])
{
    SetSuspendState(TRUE, FALSE, FALSE);

    return 0;
}

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.
Posted
Updated 9-Nov-11 0:34am
v2
Comments
Chuck O'Toole 9-Nov-11 9:55am    
Interesting that the linker says it can't a function that take three "unsigned char" arguments yet you are calling it with three "boolean" arguments. Regardless of the linker issue, are you sure you're calling this correctly?

Where did you include PowrProf.lib? Check that it is correctly included in your project's Linker properties.
 
Share this answer
 
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 #includes.

This will only work on the Visual Studio Compiler
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900