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

Windows Kernel

Development Platform:

Visual C++

  1. /*++
  2. Microsoft Confidential
  3. Copyright (c) 1992-1997  Microsoft Corporation
  4. All rights reserved
  5. Module Name:
  6.     sysdm.c 
  7. Abstract:
  8.     Initialization code for System Control Panel Applet
  9. Author:
  10.     Eric Flo (ericflo) 19-Jun-1995
  11. Revision History:
  12.     15-Oct-1997 scotthal
  13.         Complete overhaul
  14. --*/
  15. #include "sysdm.h"
  16. #include <shsemip.h>
  17. #include <shlobjp.h>
  18. //
  19. // Constants
  20. //
  21. #define SYSDM_NUM_PAGES 5   // Number of PropPages
  22. //
  23. // Global Variables
  24. //
  25. HINSTANCE hInstance;
  26. TCHAR szShellHelp[]       = TEXT("ShellHelp");
  27. TCHAR g_szNull[] = TEXT("");
  28. UINT  uiShellHelp;
  29. TCHAR g_szErrMem[ 200 ];           //  Low memory message
  30. TCHAR g_szSystemApplet[ 100 ];     //  "System Control Panel Applet" title
  31. //
  32. // Function prototypes
  33. //
  34. void 
  35. RunApplet(
  36.     IN HWND hwnd, 
  37.     IN LPTSTR lpCmdLine
  38. );
  39. BOOL 
  40. WINAPI
  41. DllInitialize(
  42.     IN HINSTANCE hInstDLL, 
  43.     IN DWORD dwReason, 
  44.     IN LPVOID lpvReserved
  45. )
  46. /*++
  47. Routine Description:
  48.     Main entry point.
  49. Arguments:
  50.     hInstDLL -
  51.         Supplies DLL instance handle.
  52.     dwReason -
  53.         Supplies the reason DllInitialize() is being called.
  54.     lpvReserved -
  55.         Reserved, NULL.
  56. Return Value:
  57.     BOOL
  58. --*/
  59. {
  60.     if (dwReason == DLL_PROCESS_DETACH)
  61.         MEM_EXIT_CHECK();
  62.     if (dwReason != DLL_PROCESS_ATTACH) {
  63.         return TRUE;
  64.     }
  65.     hInstance = hInstDLL;
  66.     return TRUE;
  67. }
  68. LONG 
  69. APIENTRY
  70. CPlApplet( 
  71.     IN HWND hwnd, 
  72.     IN WORD wMsg, 
  73.     IN LPARAM lParam1, 
  74.     IN LPARAM lParam2
  75. )
  76. /*++
  77. Routine Description:
  78.     Control Panel Applet entry point.
  79. Arguments:
  80.     hwnd -
  81.         Supplies window handle.
  82.     wMsg -
  83.         Supplies message being sent.
  84.     lParam1 -
  85.         Supplies parameter to message.
  86.     lParam2 -
  87.         Supplies parameter to message.
  88. Return Value:
  89.     Nonzero if message was handled.
  90.     Zero if message was unhandled. 
  91. --*/
  92. {
  93.     LPCPLINFO lpCPlInfo;
  94.     switch (wMsg) {
  95.         case CPL_INIT:
  96.             uiShellHelp = RegisterWindowMessage (szShellHelp);
  97.             LoadString( hInstance, INITS,   g_szErrMem,       ARRAYSIZE( g_szErrMem ) );
  98.             LoadString( hInstance, INITS+1, g_szSystemApplet, ARRAYSIZE( g_szSystemApplet ) );
  99.             return (LONG) TRUE;
  100.         case CPL_GETCOUNT:
  101.             return 1;
  102.         case CPL_INQUIRE:
  103.             lpCPlInfo = (LPCPLINFO)lParam2;
  104.             lpCPlInfo->idIcon = ID_ICON;
  105.             lpCPlInfo->idName = IDS_NAME;
  106.             lpCPlInfo->idInfo = IDS_INFO;
  107.             return (LONG) TRUE;
  108.         case CPL_DBLCLK:
  109.             lParam2 = 0L;
  110.             // fall through...
  111.         case CPL_STARTWPARMS:
  112.             RunApplet(hwnd, (LPTSTR)lParam2);
  113.             return (LONG) TRUE;
  114.     }
  115.     return (LONG)0;
  116. }
  117. void 
  118. RunApplet(
  119.     IN HWND hwnd, 
  120.     IN LPTSTR lpCmdLine
  121. )
  122. /*++
  123. Routine Description:
  124.     CPL_STARTWPARMS message handler.  Called when the user
  125.     runs the Applet.
  126.     PropSheet initialization occurs here.
  127. Arguments:
  128.     hwnd -
  129.         Supplies window handle.
  130.     lpCmdLine -
  131.         Supplies the command line used to invoke the applet.
  132. Return Value:
  133.     none
  134. --*/
  135. {
  136.     HPROPSHEETPAGE hPages[SYSDM_NUM_PAGES];
  137.     PROPSHEETHEADER psh;
  138.     UINT iPage = 0;
  139.     hPages[iPage] = CreateGeneralPage(hInstance);
  140.     if (hPages[iPage] != NULL) {
  141.         iPage++;
  142.     } // if
  143.     hPages[iPage] = CreateNetIDPage(hInstance);
  144.     if (hPages[iPage] != NULL) {
  145.         iPage++;
  146.     } // if
  147.     hPages[iPage] = CreateHardwarePage(hInstance);
  148.     if (hPages[iPage] != NULL) {
  149.         iPage++;
  150.     } // if
  151.     hPages[iPage] = CreateProfilePage(hInstance);
  152.     if (hPages[iPage] != NULL) {
  153.         iPage++;
  154.     } // if
  155.     hPages[iPage] = CreateAdvancedPage(hInstance);
  156.     if (hPages[iPage] != NULL) {
  157.         iPage++;
  158.     } // if
  159.     psh.dwSize = sizeof(PROPSHEETHEADER);
  160.     psh.dwFlags = 0;
  161.     psh.hwndParent = hwnd;
  162.     psh.hInstance = hInstance;
  163.     psh.pszCaption = MAKEINTRESOURCE(IDS_TITLE);
  164.     psh.nPages = iPage++;
  165.     psh.nStartPage = ( ( lpCmdLine && *lpCmdLine )? StringToInt( lpCmdLine ) : 0 );
  166.     psh.phpage = hPages;
  167.     if (PropertySheet (&psh) == ID_PSREBOOTSYSTEM) {
  168.         RestartDialog (hwnd, NULL, EWX_REBOOT);
  169.     } // if
  170.     return;
  171. }