init.c
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 4k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #include <windows.h>
  2. #include <cpl.h>
  3. #include <commctrl.h>
  4. #include "rc.h"
  5. #include "deskid.h"
  6. #include "desk.h"
  7. #include "setinc.h"
  8. //
  9. // Marks code that will need to be modified if this module is ever
  10. // incorporated into MAIN.CPL instead of being a separate applet.
  11. //
  12. #define NOTINMAIN
  13. #ifdef NOTINMAIN
  14. //#include "..maincphelp.h"         //For the help id's.
  15. #endif //NOTINMAIN
  16. //#define szPREVIEW   TEXT("PreviewWndClass")
  17. LONG APIENTRY CPlApplet(
  18.     HWND  hwnd,
  19.     WORD  message,
  20.     DWORD wParam,
  21.     LONG  lParam)
  22. {
  23.     LPCPLINFO lpCPlInfo;
  24.     LPNEWCPLINFO lpNCPlInfo;
  25.     WNDCLASS cls;
  26.     switch (message)
  27.     {
  28.       case CPL_INIT:          // Is any one there ?
  29.         /*
  30.          * Init the common controls
  31.          */
  32.         if (!DeskInitCpl())
  33.             return 0;
  34.         // Init the settings page code
  35.         SettingsCPlApplet( hwnd, message, wParam, lParam );
  36.         /*
  37.          * Load ONE string for emergencies.
  38.          */
  39.         LoadString (hInstance, IDS_DESK_NOMEM, gszNoMem, ARRAYSIZE(gszNoMem));
  40.         LoadString (hInstance, IDS_DISPLAY_TITLE, gszDeskCaption, ARRAYSIZE(gszDeskCaption));
  41.         return !0;
  42.       case CPL_GETCOUNT:        // How many applets do you support ?
  43.         return 1;
  44.       case CPL_INQUIRE:         // Fill CplInfo structure
  45.         lpCPlInfo = (LPCPLINFO)lParam;
  46.         lpCPlInfo->idIcon = IDI_DISPLAY;
  47.         lpCPlInfo->idName = IDS_NAME;
  48.         lpCPlInfo->idInfo = IDS_INFO;
  49.         lpCPlInfo->lData  = 0;
  50.         break;
  51.     case CPL_NEWINQUIRE:
  52.         lpNCPlInfo = (LPNEWCPLINFO)lParam;
  53.         lpNCPlInfo->hIcon = LoadIcon(hInstance, (LPTSTR) MAKEINTRESOURCE(IDI_DISPLAY));
  54.         LoadString(hInstance, IDS_NAME, lpNCPlInfo->szName, ARRAYSIZE(lpNCPlInfo->szName));
  55.         if (!LoadString(hInstance, IDS_INFO, lpNCPlInfo->szInfo, ARRAYSIZE(lpNCPlInfo->szInfo)))
  56.             lpNCPlInfo->szInfo[0] = (TCHAR) 0;
  57.         lpNCPlInfo->dwSize = sizeof( NEWCPLINFO );
  58.         lpNCPlInfo->lData  = 0;
  59. #if 0
  60.         lpNCPlInfo->dwHelpContext = IDH_CHILD_DISPLAY;
  61.         lstrcpy(lpNCPlInfo->szHelpFile, xszControlHlp);
  62. #else
  63.         lpNCPlInfo->dwHelpContext = 0;
  64.         lstrcpy(lpNCPlInfo->szHelpFile, TEXT(""));
  65. #endif
  66.         return TRUE;
  67.       case CPL_DBLCLK:          // You have been chosen to run
  68.         /*
  69.          * One of your applets has been double-clicked.
  70.          *      wParam is an index from 0 to (NUM_APPLETS-1)
  71.          *      lParam is the lData value associated with the applet
  72.          */
  73.         lParam = 0L;
  74.         // fall through...
  75.       case CPL_STARTWPARMS:
  76.         DeskShowPropSheet( hInstance, hwnd, (LPTSTR)lParam );
  77.         return TRUE;            // Tell RunDLL.exe that I succeeded
  78.       case CPL_EXIT:            // You must really die
  79.       case CPL_STOP:            // You must die
  80.         break;
  81.       case CPL_SELECT:          // You have been selected
  82.         /*
  83.          * Sent once for each applet prior to the CPL_EXIT msg.
  84.          *      wParam is an index from 0 to (NUM_APPLETS-1)
  85.          *      lParam is the lData value associated with the applet
  86.          */
  87.         break;
  88.       //
  89.       //  Private message sent when this applet is running under "Setup"
  90.       //
  91.       case CPL_SETUP:
  92.         gbExecMode = EXEC_SETUP;
  93.         break;
  94.     }
  95.     return 0L;
  96. }
  97. BOOL DllInitialize(
  98.     IN PVOID hmod,
  99.     IN ULONG ulReason,
  100.     IN PCONTEXT pctx OPTIONAL)
  101. {
  102.     UNREFERENCED_PARAMETER(pctx);
  103.     if (ulReason == DLL_PROCESS_ATTACH)
  104.     {
  105.         SettingsDllInitialize( hmod, ulReason, pctx );
  106.         hInstance = hmod;
  107.         DisableThreadLibraryCalls(hInstance);
  108.     }
  109.         
  110.     return TRUE;
  111. }