Created
December 22, 2017 14:08
-
-
Save Ishibasystems/58e261c721ff56099b20644a88d51f47 to your computer and use it in GitHub Desktop.
コマンドラインからWindowsをスリープする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* SetSuspendState suspend.c */ | |
/* コマンドラインからWindowsをスリープする */ | |
/* 2017.12.22, 10RU004, 石橋祥太 */ | |
/* lcc-win32、lcc-win64でコンパイル確認 */ | |
/* lcc.exe suspend.c */ | |
/* lcclnk.exe -subsystem windows -o suspend.exe suspend.obj */ | |
/* del suspend.obj */ | |
#include <windows.h> | |
typedef BOOL ( WINAPI *Func ) ( BOOL, BOOL, BOOL ); | |
int main ( HINSTANCE hCurInst, HINSTANCE hPrevInst, WCHAR* lpsCmdLine, int nCmdShow ) | |
{ | |
BOOL res = 0; | |
Func f; | |
HMODULE hMod = LoadLibrary ( "powrprof.dll" ); | |
if ( hMod != NULL ) | |
{ | |
f = ( Func ) GetProcAddress ( hMod, "SetSuspendState" ); | |
if ( f ) res = ( *f ) ( FALSE, FALSE, FALSE ); | |
FreeLibrary ( hMod ); | |
} | |
return ( res == 0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment