Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
2.0 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: GracefulTerminateApplication.h
  3. //
  4. // Copyright (c) 2000, Microsoft Corporation
  5. //
  6. // Class to manager terminating applications gracefully.
  7. //
  8. // History: 2000-10-27 vtan created
  9. // 2000-11-04 vtan split into separate file
  10. // --------------------------------------------------------------------------
  11. #ifndef _GracefulTerminateApplication_
  12. #define _GracefulTerminateApplication_
  13. #include <lpcfus.h>
  14. // --------------------------------------------------------------------------
  15. // CGracefulTerminateApplication
  16. //
  17. // Purpose: Class that works on the user side to try to gracefully
  18. // terminate a bad process.
  19. //
  20. // History: 2000-10-27 vtan created
  21. // 2000-11-04 vtan split into separate file
  22. // --------------------------------------------------------------------------
  23. class CGracefulTerminateApplication
  24. {
  25. public:
  26. enum
  27. {
  28. NO_WINDOWS_FOUND = 47647,
  29. WAIT_WINDOWS_FOUND = 48517
  30. };
  31. public:
  32. CGracefulTerminateApplication (void);
  33. ~CGracefulTerminateApplication (void);
  34. void Terminate (DWORD dwProcessID);
  35. static void Prompt (HINSTANCE hInstance, HANDLE hProcess);
  36. private:
  37. static bool ShowPrompt (HINSTANCE hInstance, const WCHAR *pszImageName);
  38. static bool CanTerminateFirstInstance (HANDLE hPort, const WCHAR *pszImageName, WCHAR *pszUser, int cchUser);
  39. static bool TerminatedFirstInstance (HANDLE hPort, const WCHAR *pszImageName);
  40. static BOOL CALLBACK EnumWindowsProc (HWND hwnd, LPARAM lParam);
  41. private:
  42. DWORD _dwProcessID;
  43. bool _fFoundWindow;
  44. };
  45. #endif /* _GracefulTerminateApplication_ */