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.

154 lines
4.4 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. Win98, Win2000
  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 <windows.h>
  32. #include <tchar.h>
  33. #include <stdlib.h>
  34. #include <cpl.h>
  35. #include "Dlg.h"
  36. #include "Res.h"
  37. #include "keymgr.h"
  38. #include "krDlg.h"
  39. #include <wincrui.h>
  40. #include "switches.h"
  41. #include <shfusion.h>
  42. //////////////////////////////////////////////////////////////////////////////
  43. //
  44. // Static initialization
  45. //
  46. static const char _THIS_FILE_[ ] = __FILE__;
  47. //static const WORD _THIS_MODULE_ = LF_MODULE_UPGRADE;
  48. //////////////////////////////////////////////////////////////////////////////
  49. //
  50. // Global state info
  51. //
  52. HINSTANCE g_hInstance = NULL;
  53. C_KeyringDlg *pDlg = NULL;
  54. void WINAPI KRShowKeyMgr(HWND,HINSTANCE,LPWSTR,int);
  55. extern "C"LONG APIENTRY CPlApplet(HWND hwndCPl,UINT uMsg,LPARAM lParam1,LPARAM lParam2)
  56. {
  57. INT_PTR nResult;
  58. CPLINFO *lpCPlInfo;
  59. // Handle commands to this dll/cpl from the enclosing presentation app.
  60. // Default return from any command is 0 (success), except those commands
  61. // which ask for specific data in the return value
  62. switch(uMsg) {
  63. case CPL_INIT:
  64. g_hInstance = GetModuleHandle(L"keymgr.dll");
  65. if (NULL == g_hInstance) {
  66. #ifdef LOUDLY
  67. MessageBox(NULL,L"DLL Init",NULL,MB_OK);
  68. #endif
  69. return FALSE;
  70. }
  71. return TRUE;
  72. break;
  73. case CPL_GETCOUNT:
  74. return 1; // only 1 applet icon in this cpl file
  75. break;
  76. case CPL_NEWINQUIRE:
  77. break;
  78. case CPL_INQUIRE:
  79. lpCPlInfo = (CPLINFO *) lParam2; // acquire ptr to target data
  80. lpCPlInfo->lData = 0; // no effect
  81. lpCPlInfo->idIcon = IDI_UPGRADE; // store items needed to show the applet
  82. lpCPlInfo->idName = IDS_APP_NAME;
  83. lpCPlInfo->idInfo = IDS_APP_DESCRIPTION; // description string
  84. break;
  85. case CPL_DBLCLK:
  86. #ifdef LOUDLY
  87. MessageBox(NULL,L"DLL Select",NULL,MB_OK);
  88. #endif
  89. // user has selected this cpl applet - put up our dialog
  90. if (NULL == pDlg){
  91. KRShowKeyMgr(NULL,g_hInstance,NULL,0);
  92. #if 0
  93. INITCOMMONCONTROLSEX stICC;
  94. BOOL fICC;
  95. stICC.dwSize = sizeof(INITCOMMONCONTROLSEX);
  96. stICC.dwICC = ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES;
  97. fICC = InitCommonControlsEx(&stICC);
  98. #ifdef LOUDLY
  99. if (fICC) OutputDebugString(L"Common control init OK\n");
  100. else OutputDebugString(L"Common control init FAILED\n");
  101. #endif
  102. if (!CredUIInitControls()) return 1;
  103. pDlg = new C_KeyringDlg(NULL, g_hInstance, IDD_KEYRING, NULL);
  104. // nonzero return on failure to allocate the dialog object
  105. if (NULL == pDlg) return 1;
  106. nResult = pDlg->DoModal((LPARAM)pDlg);
  107. #endif
  108. }
  109. break;
  110. case CPL_STOP:
  111. #ifdef LOUDLY
  112. MessageBox(NULL,L"DLL Stop",NULL,MB_OK);
  113. #endif
  114. if (NULL != pDlg) {
  115. delete pDlg;
  116. pDlg = NULL;
  117. }
  118. break;
  119. case CPL_EXIT:
  120. break;
  121. default:
  122. break;
  123. }
  124. return 0;
  125. }