netripper

netripper

Dec 30th, 2009
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.37 KB | None | 0 0
  1. // KeypadLedControlSetupActions.cpp : Defines the entry point for the DLL application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "ce_setup.h"
  6.  
  7.  
  8. BOOL APIENTRY DllMain( HANDLE hModule,
  9.                        DWORD  ul_reason_for_call,
  10.                        LPVOID lpReserved
  11.                      )
  12. {
  13.     return TRUE;
  14. }
  15.  
  16. // Use this method to close the app.
  17. bool CloseKeypadLedControlApp(void)
  18. {
  19.     // Before (un)installing, we need to shut down the existing KeypadLedControl. We'll use the Event for this which we have since the first version.
  20.     HANDLE appEvent = CreateEvent(NULL, TRUE, FALSE, L"KeypadLedControlApp");
  21.     if (appEvent == NULL)
  22.     {
  23.         // I won't understand why we couldn't create this event. Weird out-of-memory maybe. We failed.
  24.         return false;
  25.     }
  26.  
  27.     // See if the event already existed
  28.     if (GetLastError() == ERROR_ALREADY_EXISTS)
  29.     {
  30.         // Event exists, means the app is running! Signal the event to close the app.
  31.         SetEvent(appEvent);
  32.         CloseHandle(appEvent);
  33.  
  34.         // Wait a second to allow the app to exit.
  35.         Sleep(1000);
  36.     }
  37.     else
  38.     {
  39.         // The event doesn't exist. The app isn't running.
  40.         CloseHandle(appEvent);
  41.     }
  42.     return true;
  43. }
  44.  
  45. codeINSTALL_INIT
  46. Install_Init(
  47.              HWND        hwndParent,
  48.              BOOL        fFirstCall,     // is this the first time this function is being called?
  49.              BOOL        fPreviouslyInstalled,
  50.              LPCTSTR     pszInstallDir
  51.              )
  52. {
  53.     if (CloseKeypadLedControlApp())
  54.     {
  55.         return codeINSTALL_INIT_CONTINUE;
  56.     }
  57.     return codeINSTALL_INIT_CANCEL;
  58. }
  59.  
  60.  
  61.  
  62. codeINSTALL_EXIT
  63. Install_Exit(
  64.              HWND    hwndParent,
  65.              LPCTSTR pszInstallDir,
  66.              WORD    cFailedDirs,
  67.              WORD    cFailedFiles,
  68.              WORD    cFailedRegKeys,
  69.              WORD    cFailedRegVals,
  70.              WORD    cFailedShortcuts
  71.              )
  72. {
  73.     return codeINSTALL_EXIT_DONE;
  74. }
  75.  
  76. codeUNINSTALL_INIT
  77. Uninstall_Init(
  78.                HWND        hwndParent,
  79.                LPCTSTR     pszInstallDir
  80.                )
  81. {
  82.     if (CloseKeypadLedControlApp())
  83.     {
  84.         return codeUNINSTALL_INIT_CONTINUE;
  85.     }
  86.     return codeUNINSTALL_INIT_CANCEL;
  87. }
  88.  
  89. codeUNINSTALL_EXIT
  90. Uninstall_Exit(
  91.                HWND    hwndParent
  92.                )
  93. {
  94.     return codeUNINSTALL_EXIT_DONE;
  95. }
  96.  
Add Comment
Please, Sign In to add comment