Hey there,
I'm trying to use the SetSuspendState() function to hibernate the computer, but I have no idea what parameters I should send to it. The prototype is "BOOLEAN WINAPI SetSuspendState(BOOLEAN, BOOLEAN, BOOLEAN);"
Since I'm a somewhat beginner in c++ programming, I don't really have an idea what BOOLEAN means and what I should send as a BOOLEAN. I tried the "true" and "false", numbers and variables, but none worked.
The compiler error is as follows:
[Linker error] undefined reference to `SetSuspendState@12'
By the way -- I'm using Dev-C++ 4.9.9.2
I checked about SetSuspendState() in DaniWeb, and googled it, but came up with nothing.
Thanks in advance to the helpers!

>>I checked about SetSuspendState() in DaniWeb, and googled it, but came up with nothing.
Not supprised about DaniWeb, but google had lots of links

Always either search MSDN or google for all win32 api functions, and they will give you detailed information. Here is the information you need.

I checked about SetSuspendState() in DaniWeb, and googled it, but came up with nothing.
Thanks in advance to the helpers!

Are you sure you googled it? There's about a billion relevant hits on 'setsupendstate'.

from the horses mouth:
http://msdn.microsoft.com/en-us/library/aa373201.aspx

BOOLEAN is true/false (1/0).

The linker error you got (couldn't find xxx) is because you haven't included the powerprof.a library in your project. Go to project options, parameters, add library or object, find libpowrprof.a. Will work after that.

I don't have the option to choose "project options", since it's not in a project.
Is there a way I can do it not in a project?

You have to make a project then it will work. Just create a new project and copy the file into it.

Now I get this error:
"26 E:\C++_programs\Makefile.win [Build Error] *** target pattern contains no `%'. Stop. "
(after making it a project and including the said file)

Let me have a look in my crystal ball....

I think you have an error on line 26, and it probably has something to do with a '%' ....

In other words: post the code

commented: You must need new glasses :) +36
#include<iostream> //cout and cin 
#include<conio.h> //getch()
#include<stdlib.h>
#include<windows.h>
#include <cstdlib>
#include<PowrProf.h> //SetSuspendState()

using namespace std;
int main(int argc, char *argv[])
{
SetSuspendState(true,false,false);
getch();
return 0;
}

The error points line 26 in another file, named Makefile.win
Here's that line:
$(BIN): $(OBJ)

Your program compiles/links ok for me. Instead of powerprof.a you have to link with libpowerprof.a.

This is the file included:
C:/Dev-Cpp/lib/libpowrprof.a
It just won't compile...

$(BIN): $(OBJ)

Those macros are defined elsewhere in the makefile, and that line shows very little information about your specific problem. Post the whole makefile.

# Project: Project2
# Makefile created by Dev-C++ 4.9.9.2

CPP  = g++.exe -D__DEBUG__
CC   = gcc.exe -D__DEBUG__
WINDRES = windres.exe
RES  = 
OBJ  = "C:/Documents\ and\ Settings/U1/Desktop/main.o" $(RES)
LINKOBJ  = "C:/Documents and Settings/U1/Desktop/main.o" $(RES)
LIBS =  -L"C:/Dev-Cpp/lib" C:/Dev-Cpp/lib/libpowrprof.a  -g3 
INCS =  -I"C:/Dev-Cpp/include" 
CXXINCS =  -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include" 
BIN  = Project2.exe
CXXFLAGS = $(CXXINCS)   -g3
CFLAGS = $(INCS)   -g3
RM = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before Project2.exe all-after


clean: clean-custom
	${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
	$(CPP) $(LINKOBJ) -o "Project2.exe" $(LIBS)

"C:/Documents\ and\ Settings/U1/Desktop/main.o": C:/Documents\ and\ Settings/U1/Desktop/main.cpp
	$(CPP) -c "C:/Documents and Settings/U1/Desktop/main.cpp" -o "C:/Documents and Settings/U1/Desktop/main.o" $(CXXFLAGS)

move your project to a folder that does not contain spaces, such as c:\dev-c++\source

commented: Making the rep count as requisted by OP :) +9

"move your project to a folder that does not contain spaces, such as c:\dev-c++\source"

Thanks! I didn't think it'll make a trouble to create it on the desktop. It works great now!
You deserve a reputation point from me :P
Thanks again!

The project compiles when source is on the desktop and project is somewhere else.

Have you determined whether there's more than 1 gcc compiler present yet?

You can always uninstall dev-c++, and reinstall it. To check for another gcc: uninstall dev-c++, from the command prompt run "gcc" - if something runs, then gcc is present.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.