Leaked source code of windows server 2003
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.

146 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. KEYMGR.CPP
  5. Abstract:
  6. Keyring WinMain() and application support
  7. Author:
  8. 990917 johnhaw Created.
  9. georgema 000310 updated
  10. georgema 000501 used to be EXE, changed to CPL
  11. Comments:
  12. This executable is the control panel applet to allow a user some control
  13. over the contents of the Windows Keyring, the so-called "Geek UI". It was
  14. originally an EXE, but that architecture is not as optimized for merging
  15. with other control panel applets. It has been changed to a CPL executable,
  16. and can be either left as a CPL if it is desired that it should show up
  17. automatically in the master control panel window, or rahter renamed to
  18. a DLL file extension if it is desired that a control panel applet container
  19. application should load it explicitly without it otherwise being visible
  20. to the system.
  21. Environment:
  22. WinXP
  23. Revision History:
  24. --*/
  25. #pragma comment(user, "Compiled on " __DATE__ " at " __TIME__)
  26. #pragma comment(compiler)
  27. //////////////////////////////////////////////////////////////////////////////
  28. //
  29. // Include files
  30. //
  31. #include <nt.h>
  32. #include <ntrtl.h>
  33. #include <nturtl.h>
  34. #include <windows.h>
  35. #include <stdlib.h>
  36. #include <cpl.h>
  37. #include <wincred.h>
  38. #include <wincrui.h>
  39. #include <shfusion.h>
  40. #include <scuisupp.h>
  41. #include <lmcons.h>
  42. #include "switches.h"
  43. #include "Dlg.h"
  44. #include "Res.h"
  45. #include "keymgr.h"
  46. #include "krDlg.h"
  47. //////////////////////////////////////////////////////////////////////////////
  48. //
  49. // Static initialization
  50. //
  51. static const char _THIS_FILE_[ ] = __FILE__;
  52. //////////////////////////////////////////////////////////////////////////////
  53. //
  54. // Global state info
  55. //
  56. C_KeyringDlg *pDlg = NULL;
  57. /**********************************************************************
  58. CPlApplet is the entrypoint for a control panel applet. This entry point
  59. is used by keymgr.cpl, generated in the keycpl project. The decision to
  60. implement this cpl functionality in keymgr.dll, rather than in keymgr.cpl,
  61. allows the implementation of keymgr to be contained entirely within
  62. keymgr.dll, as a common component, without need to update the cpl version
  63. if changes are made to the dll. The cpl is a very thin wrapper for the dll.
  64. **********************************************************************/
  65. extern "C"LONG APIENTRY CPlApplet(HWND hwndCPl,UINT uMsg,LPARAM lParam1,LPARAM lParam2)
  66. {
  67. CPLINFO *lpCPlInfo;
  68. // Handle commands to this dll/cpl from the enclosing presentation app.
  69. // Default return from any command is 0 (success), except those commands
  70. // which ask for specific data in the return value
  71. switch(uMsg)
  72. {
  73. case CPL_INIT:
  74. g_hInstance = GetModuleHandle(L"keymgr.dll");
  75. if (NULL == g_hInstance)
  76. {
  77. ASSERT(g_hInstance);
  78. return FALSE;
  79. }
  80. return TRUE;
  81. break;
  82. case CPL_GETCOUNT:
  83. return 1; // only 1 applet icon in this cpl file
  84. break;
  85. case CPL_NEWINQUIRE:
  86. break;
  87. case CPL_INQUIRE:
  88. ASSERT(lParam2);
  89. lpCPlInfo = (CPLINFO *) lParam2; // acquire ptr to target data
  90. lpCPlInfo->lData = 0; // no effect
  91. lpCPlInfo->idIcon = IDI_UPGRADE; // store items needed to show the applet
  92. lpCPlInfo->idName = IDS_APP_NAME;
  93. lpCPlInfo->idInfo = IDS_APP_DESCRIPTION; // description string
  94. break;
  95. case CPL_DBLCLK:
  96. // user has selected this cpl applet - put up our dialog
  97. if (NULL == pDlg)
  98. {
  99. KRShowKeyMgr(NULL,g_hInstance,NULL,0);
  100. }
  101. break;
  102. case CPL_STOP:
  103. delete pDlg;
  104. pDlg = NULL;
  105. break;
  106. case CPL_EXIT:
  107. break;
  108. default:
  109. ASSERT(0); // surprising function code
  110. break;
  111. }
  112. return 0;
  113. }