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
[27415] Re:Tray에서 폼 없애기
smleelms [smleelms] 886 읽음    2003-10-07 14:06
플그램 님이 쓰신 글 :
: 빌더5에서 간단하게 트레이를 구현하려고 합니다.
: 트레이에 생성은 되는데 폼을 없애려고 하는데 방법을 잘 몰라서 고수님들에게 부탁드립니다.
: 1. 트레이에서 폼 없애기
: 2. 시간을 콤보박스에서 선택후 그 시간이 되면 시스템 종료--소스가 있으시면 알려주시면 감사^^
: 3. 응용 프로그램 등록
:
: 위 세가지를 할 예정입니다.
: 간단하게라도 알려주시면 고맙겠습니다.

1. 폼 없애기

// 폼 없애기
void __fastcall TForm1::btnHideClick(TObject *Sender)
{
    Form1->Hide();
    TrayIcon1->Visible = true;
    ShowWindow(Application->Handle, SW_HIDE);
}
// 폼 다시 불러내기
void __fastcall TForm1::TrayIcon1Click(TObject *Sender)
{
    TrayIcon1->Visible = false;
    Form1->Show();
    ShowWindow(Application->Handle, SW_RESTORE);
}


2. 시스템 종료 루틴

    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);

=-=-=-=-=-=-=
ExitWindowsEx() 함수를 쓰시면 됩니다. 함수원형은 다음과 같습니다.

BOOL ExitWindowsEx(

    UINT uFlags,    // shutdown operation
    DWORD dwReserved     // reserved
   );

그리고 uFlag를 상황에 따라 골라쓰시면 되겠네요..

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.
=-=-=-=-=-=-=

그리고... 3번째는 정확히 어떤것을 말씀하시는지 모르겠네요.. ^^;

+ -

관련 글 리스트
27414 Tray에서 폼 없애기 플그램 597 2003/10/07
27415     Re:Tray에서 폼 없애기 smleelms 886 2003/10/07
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.