= \@bcat |
= \@scat |
= \@cat{Programming} |
= \@cat{wikiX} |
= \@ecat |
= \TableOfContents |
= |
= /*! wikiXmacros¿Í \\basis \\easis ÀÌ¿ë*/ |
= \def@bverb={ |
= <tt> |
= \dcSave |
= \noDefault |
= } |
= \def@everb={ |
= \dcRestore |
= </tt> |
= } |
= \def@bverbox=<table style="background-color:#eeeeee; border:1 solid;"><tr><td>\@bverb |
= \def@everbox=\@everb</td></tr></table> |
= |
= !À©µµ¿ìÁî 2000,XP ÆÄ¿ö ²ô±â, ¸®ºÎÆÃÇϱâ |
= 2001³âµµ¿¡ ®´ø °Í °°³×¿ä. À©µµ¿ìÁî2000 °è¿ÀÇ ÆÄ¿ö ²ô´Â ¼Ò½ºÄÚµåÀÔ´Ï´Ù.%%% VC6.0À¸·Î ®°í, MFC¸¦ »ç¿ëÇÕ´Ï´Ù. ÇÁ·Î±×·¥À» ÇÏ½Ç ÁÙ ¾Æ½Ã¸é ¹¹ÇÏ´Â °ÍÀÎ Áö ±Ý¹æ ¾Æ½Ç µí.%%% |
= ´ÙÀ½Àº ºôµåÇÑ ½ÇÇàÆÄÀÏÀÔ´Ï´Ù.%%%ÀÌ Äڵ尡 ¾îµð¼ º» °ÍÀ¸·Î § °Å¶ó¼(¾îµð¿´´õ¶ó..?) »ó¾÷ÀûÀ¸·Î ±×´ë·Î ¾²¸é ¾ÈµÉ °Ì´Ï´Ù.%%% |
= °ü·Ã MSDN ¸µÅ©´Â [ ¿©±â | http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/how_to_shut_down_the_system.asp ] ÀÔ´Ï´Ù. |
= |
= | ¼³¸í | ÆÄÀÏ | size | md5sum |
- | ÆÄ¿ö ²ô´Â ÇÁ·Î±×·¥ | [ poweroff.exe | http://host/~rommance/data/poweroff.exe] | 20480 bytes | 4d4b1636cf14891a8ddda52d343a3b39%%% |
- | ÀçºÎÆÃÇÏ´Â ÇÁ·Î±×·¥ | [ reboot.exe | http://host/~rommance/data/reboot.exe] | 20480 bytes | 0945bb917736b4718ca26523223bb1f8 |
+ | ÆÄ¿ö ²ô´Â ÇÁ·Î±×·¥ | [ poweroff.exe | http://host/data/poweroff.exe] | 20480 bytes | 4d4b1636cf14891a8ddda52d343a3b39%%% |
+ | ÀçºÎÆÃÇÏ´Â ÇÁ·Î±×·¥ | [ reboot.exe | http://host/data/reboot.exe] | 20480 bytes | 0945bb917736b4718ca26523223bb1f8 |
= |
= \PwrTest.h |
= \@bverbox |
= \basis |
= |
= #if !defined(AFX_PWRTEST_H__149C02D0_B545_4699_A4A5_DFDB719EFBFB__INCLUDED_) |
= #define AFX_PWRTEST_H__149C02D0_B545_4699_A4A5_DFDB719EFBFB__INCLUDED_ |
= |
= #if _MSC_VER > 1000 |
= #pragma once |
= #endif // _MSC_VER > 1000 |
= |
= #include "resource.h" |
= |
= /////////////// Jiseok |
= int PowerOff(); |
= int Reboot(); |
= int GetWinVersion(OSVERSIONINFO* windowsversion); |
= int DoPowerOff(OSVERSIONINFO* windowsversion); |
= int DoReboot(OSVERSIONINFO* windowsversion); |
= int AquirePrivileges(OSVERSIONINFO* windowsversion); |
= ////////////// end Jiseok |
= |
= #endif // !defined(AFX_PWRTEST_H__149C02D0_B545_4699_A4A5_DFDB719EFBFB__INCLUDED_) |
= \easis |
= \@everbox |
= |
= \PwrTest.cpp |
= \@bverbox |
= \basis |
= // PwrTest.cpp : Defines the entry point for the console application. |
= // |
= |
= #include "stdafx.h" |
= #include "PwrTest.h" |
= |
= #ifdef _DEBUG |
= #define new DEBUG_NEW |
= #undef THIS_FILE |
= static char THIS_FILE[] = __FILE__; |
= #endif |
= |
= ///////////////////////////////////////////////////////////////////////////// |
= // The one and only application object |
= |
= CWinApp theApp; |
= |
= using namespace std; |
= |
= int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) |
= { |
= int nRetCode = 0; |
= |
= // initialize MFC and print and error on failure |
= if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) |
= { |
= // TODO: change error code to suit your needs |
= cerr << _T("Fatal Error: MFC initialization failed") << endl; |
= nRetCode = 1; |
= } |
= else |
= { |
= // TODO: code your application's behavior here. |
= |
= //////////////// Jiseok |
= //if (PowerOff()!=0) |
= if (Reboot()!=0) |
= return 1; |
= //////////////// end Jiseok |
= |
= CString strHello; |
= strHello.LoadString(IDS_HELLO); |
= cout << (LPCTSTR)strHello << endl; |
= } |
= |
= return nRetCode; |
= } |
= |
= |
= |
= ///////////////// Jiseok |
= |
= int PowerOff() |
= { |
= OSVERSIONINFO Version; |
= |
= if (GetWinVersion(&Version)!=0) |
= return -1; |
= if (DoPowerOff(&Version)!=0) |
= return -1; |
= return 0; |
= } |
= |
= int Reboot() |
= { |
= OSVERSIONINFO Version; |
= |
= if (GetWinVersion(&Version)!=0) |
= return -1; |
= if (DoReboot(&Version)!=0) |
= return -1; |
= return 0; |
= } |
= |
= int GetWinVersion(OSVERSIONINFO* windowsversion) |
= { |
= windowsversion->dwOSVersionInfoSize=sizeof(OSVERSIONINFO); |
= if (!GetVersionEx(windowsversion)) |
= { |
= printf("Error! getting version info"); |
= return -1; |
= } |
= return 0; |
= } |
= |
= int DoPowerOff(OSVERSIONINFO* windowsversion) |
= { |
= UINT mode; |
= |
= if (windowsversion->dwPlatformId==VER_PLATFORM_WIN32_WINDOWS) |
= mode=EWX_SHUTDOWN; |
= else |
= mode=EWX_POWEROFF; |
= |
= if (windowsversion->dwPlatformId==VER_PLATFORM_WIN32_NT) |
= { |
= // privilege ¾ò±â |
= if (AquirePrivileges(windowsversion)!=0) |
= { |
= return -1; |
= }//if |
= }// if |
= |
= if (!ExitWindowsEx(mode,0)) // ²ô±â |
= { |
= printf("error ExitWindowsEx"); |
= return -1; |
= } |
= return 0; |
= } |
= |
= |
= int DoReboot(OSVERSIONINFO* windowsversion) |
= { |
= UINT mode; |
= |
= mode=EWX_REBOOT; |
= |
= if (windowsversion->dwPlatformId==VER_PLATFORM_WIN32_NT) |
= { |
= // privilege ¾ò±â |
= if (AquirePrivileges(windowsversion)!=0) |
= { |
= return -1; |
= }//if |
= }// if |
= |
= if (!ExitWindowsEx(mode,0)) // ²ô±â |
= { |
= printf("error ExitWindowsEx"); |
= return -1; |
= } |
= return 0; |
= } |
= |
= int AquirePrivileges(OSVERSIONINFO* windowsversion) |
= { |
= HANDLE current_thread,token; |
= TOKEN_PRIVILEGES privs; |
= LUID luid; |
= |
= current_thread=GetCurrentProcess(); |
= if (!OpenProcessToken(current_thread,TOKEN_ADJUST_PRIVILEGES,&token)) |
= { |
= printf("Error! opening process token"); |
= return -1; |
= } |
= if (!LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&luid)) |
= { |
= printf("Error! looking up privilege"); |
= return -1; |
= } |
= privs.PrivilegeCount=1; |
= privs.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED; |
= privs.Privileges[0].Luid=luid; |
= if (!AdjustTokenPrivileges(token,FALSE,&privs,0,NULL,NULL)) |
= { |
= printf("Error! getting privileges"); |
= return -1; |
= } |
= return 0; |
= } |
= |
= //////////// end Jiseok |
= |
= \easis |
= \@everbox |
= |
= \@bcat |
= \@scat |
= \@cat{Programming} |
= \@cat{wikiX} |
= \@ecat |