SetSuspendState() function program errors

Oct 7, 2009 at 10:01pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <powrprof.h>
#include <std_lib_facilities.h>
#define new '\n'
using namespace std;
int choice;


int main ()
{
top:    
    cout << "Power Manager V1" << new;
    cout << "To Hibernate == 1" << new;
    cout << new;
    cout << "To power off == 2" << new;
    cout << new;
    cout << "To stand == 3" << new;
    cout << new;
    cout << "To restart == 4" << new;
    cout << new;
    cin >> choice;
         {
                  
if (choice == 1)
{  goto a1;
}

a1:
        BOOLEAN WINAPI SetSuspendState(
  __ true  BOOLEAN Hibernate,
  __ false  BOOLEAN ForceCritical,
  __ false  BOOLEAN DisableWakeEvent
);
keep_window_open();
return 0;
}
}


im a noob so i may look stupid but why are there so many errors in this and when i compile it the file ndef pops up and the compiler shows errors from that too so please help...


and i havent added in all the options yet because of i want to test it first


EDIT: i know i am using goto wrong
Last edited on Oct 7, 2009 at 10:50pm
Oct 8, 2009 at 11:56am
Why have you pasted the api declaration inside main() ?!!
Oct 8, 2009 at 9:34pm
i was trying to make a menu to hiberante and power off and restart and stuff
Oct 9, 2009 at 5:33am
new is a keyword!
Oct 16, 2009 at 12:18am
You're already using the namespace std, just use cout << endl; to print new lines; as for SetSuspendState.. you know what, fuck it, here you go:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <windows.h>
#include <iostream>
#include <PowrProf.h>

#pragma comment(lib, "PowrProf.lib")

using namespace std;

int main()
{
  int choice;
  
  cout << "Power Manager V1" << endl
    << "To Hibernate == 1" << endl
    << "To power off == 2" << endl
    << "To stand == 3" << endl
    << "To restart == 4" << endl;
  cin >> choice;
  
  if(choice == 1)
    SetSuspendState(true, false, false);
  
  getchar();
  // just use this instead of your keep_window_open() 
  // function, which I doubt is better than getchar()

  return 0;
}


To call a function, the syntax is FunctionName(parameters); for example:
SetSuspendState /*function name*/ (true, false, false /*parameters*/)

Also, the reason you had so many errors (apart from your syntax) is probably that you didn't include windows.h, it contains definitions that PowrProf.h uses.
Last edited on Oct 16, 2009 at 12:21am
Topic archived. No new replies allowed.