简体   繁体   中英

Suspending system using c++ program

I am trying to suspend my system using a c++ program using SetSuspendState method but I am facing issue during linking.

I am using g++-4 (GCC) 4.3.4 20090804 (release) 1 compiler on Windows 7 OS (64bit).

The code I have written is

#include <iostream>
#include "windows.h"
#include "powrprof.h"

using namespace std;

int main() {

    cout << SetSuspendState(false, true, false);
    return 0;
}

Following is the error I am facing:

/cygdrive/c/Users/Vikas/AppData/Local/Temp/ccFpLgPi.o:suspend.cpp:(.text+0xa4): undefined reference to `_SetSuspendState@12' collect2: ld returned 1 exit status

Kindly help me in resolving this issue.

Thanks in advance ...

I believe dlltool can be used to create import libraries from DLLs for use with GCC under Cygwin. The DLL exporting the functions pwrprof.dll should be located in your Windows system directory somewhere.

正如msdn所说,您需要链接PowrProf.lib。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM