C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[39181] Re:컴퓨터 시간 알아내는거 질문이요!!
smleelms [smleelms] 1271 읽음    2005-02-19 12:48
void __fastcall TFormMain::Timer1Timer(TObject *Sender)  // 타이머의 타이머값은 적절히 셋팅을...
{
    TDateTime Time1, Time2;
    Word h1, m1, s1, ms1;
    Word h2, m2, s2, ms2;

    Time1 = tShutDownTime;
    Time2 = Now();

    DecodeTime(Time1, h1, m1, s1, ms1);
    DecodeTime(Time2, h2, m2, s2, ms2);

    if(h1 == h2 && m1 == m2)
    {
        HANDLE hToken;
        TOKEN_PRIVILEGES tp;
        LUID luid;
   
        OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken);
        LookupPrivilegeValue(NULL, "SeShutdownPrivilege", &luid);
   
        tp.PrivilegeCount = 1;
        tp.Privileges[0].Luid = luid;
        tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
   
        AdjustTokenPrivileges(hToken, false, &tp, 0, NULL, NULL);
        ExitWindowsEx(EWX_SHUTDOWN, 0);
    }
}
//---------------------------------------------------------------------------

EWX_FORCE
Forces processes to terminate. When this flag is set, Windows does not send the messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications currently running in the system. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.

EWX_LOGOFF
Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.

EWX_POWEROFF
Shuts down the system and turns off the power. The system must support the power-off feature.Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.

EWX_REBOOT
Shuts down the system and then restarts the system. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.

EWX_SHUTDOWN
Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.

즐코딩요~~

상우s 님이 쓰신 글 :
: 컴퓨터 에서 시작 시간 알아내는 법하고
:
: 정해진 시간이 됏을 때 윈도우 종료하는 방법좀 자세히 알려주세요
:
: 빠른답변 주시면 감사하겠습니다.

+ -

관련 글 리스트
39171 컴퓨터 시간 알아내는거 질문이요!! 상우s 924 2005/02/18
39181     Re:컴퓨터 시간 알아내는거 질문이요!! smleelms 1271 2005/02/19
39179     Re:컴퓨터 시간 알아내는거 질문이요!! 2HB 1705 2005/02/19
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.