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
[71438] Re:[질무] SystemTray의 Icon 삭제 어떻게?
gomsun2 [vhrvnd723] 3522 읽음    2014-06-19 13:45
http://delphi.cjcsoft.net/viewthread.php?tid=631

땅주인 님이 쓰신 글 :
: 개발환경: RAD Studio XE5(C++ Builder)
: 프로그램의 운영 상황에 따라 프로그램을 System Tray에 넣거나 빼거나 하는 상황입니다.
: WatchDog에서 특정 상황이 되어 대상 프로그램을 Kill 시킬 때, 이 프로그램이 System Tray에
: 있으면 Process는 Kill 되지만 System Tray의 Icon은 그대로 남아있네요.
: 프로그램이 정상 종료 절차를 밟으면 Tray Icon도 정상적으로 삭제되지만,
: WatchDog에서 강제로 Process Kill하면 Tray에 그냥 남아있는데요..
: 몇 번을 반복하면 System Tray에 동일 아이콘이 여러 개 남아 있어 보기도 좋지 않아서,
: 이를 해결했으면 하는데, 딱히 방법이 떠오르지 않네요.
:
: 감사합니다.
:
:
: //---------------------------------------------------------------------------
: // 프로그램을 System Tray에 넎는다.
: bool TFormMain::GoToSystemTray()
: {
: 	Hide();
: 	WindowState = wsMinimized;
: 	TrayIcon->Visible = true;
: 	return true;
: }
: 
: //---------------------------------------------------------------------------
: // 프로그램을 System Tray에서 빼낸다. 
: bool TFormMain::RestoreFromTray()
: {
: 	TrayIcon->Visible = false;
: 	Show();
: 	WindowState = wsNormal;
: 	Application->BringToFront();
: 	return true;
: }
: 

:
: WatchDog의 Process Kill시키는 소스..
:
: //---------------------------------------------------------------------------
: bool TFormMain::ProcessKill(UnicodeString sProcess)
: {
:    DWORD dwSize = 250;
:    HANDLE hSnapShot;
:    PROCESSENTRY32 pEntry;
:    BOOL bCurrent = FALSE;
: 
:    hSnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPALL,NULL);
: 
:    pEntry.dwSize =sizeof(pEntry);
:    Process32First (hSnapShot,&pEntry);
: 
:    bool bOk = false;
: 
:    while(TRUE)
:    {
: 	 BOOL hRes = Process32Next(hSnapShot,&pEntry);
: 	 if(hRes == FALSE) break;
: 	 if(!wcsncmp(pEntry.szExeFile, sProcess.c_str(), sProcess.Length()))
: 	 {
: 		bCurrent = TRUE;
: 	 }
: 	 if(bCurrent)
: 	 {
: 	   HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pEntry.th32ProcessID);
: 	   if(hProcess)
: 	   {
: 		  if(TerminateProcess(hProcess, 0))
: 		  {
: 			unsigned long nCode;
: 			GetExitCodeProcess(hProcess, &nCode);
: 			bOk = true;
: 		  }
: 		  CloseHandle(hProcess);
: 		}
: 	 }
: 	 bCurrent = FALSE;
:    }
:    return bOk;
: }
: 

:

+ -

관련 글 리스트
71437 [질무] SystemTray의 Icon 삭제 어떻게? 땅주인 3159 2014/06/19
71438     Re:[질무] SystemTray의 Icon 삭제 어떻게? gomsun2 3522 2014/06/19
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.