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.

129 lines
3.6 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 "Res.h"
  36. #include "keymgr.h"
  37. #undef GSHOW
  38. //////////////////////////////////////////////////////////////////////////////
  39. //
  40. // Static initialization
  41. //
  42. static const char _THIS_FILE_[ ] = __FILE__;
  43. //static const WORD _THIS_MODULE_ = LF_MODULE_UPGRADE;
  44. //////////////////////////////////////////////////////////////////////////////
  45. //
  46. // Global state info
  47. //
  48. HINSTANCE g_hInstance = NULL;
  49. HMODULE hDll = NULL;
  50. LONG (*CPlFunc)(HWND,UINT,LPARAM,LPARAM);
  51. __declspec(dllexport) LONG APIENTRY CPlApplet(HWND hwndCPl,UINT uMsg,LPARAM lParam1,LPARAM lParam2)
  52. {
  53. INT_PTR nResult;
  54. CPLINFO *lpCPlInfo;
  55. // Handle commands to this dll/cpl from the enclosing presentation app.
  56. // Default return from any command is 0 (success), except those commands
  57. // which ask for specific data in the return value
  58. switch(uMsg) {
  59. case CPL_INIT:
  60. hDll = LoadLibrary(L"keymgr.dll");
  61. if (NULL == hDll) {
  62. #ifdef GMSHOW
  63. MessageBox(NULL,L"Failed to load dll",NULL,MB_OK);
  64. #endif
  65. return FALSE;
  66. }
  67. CPlFunc = (LONG (*)(HWND,UINT,LPARAM,LPARAM)) GetProcAddress(hDll,"CPlApplet");
  68. if (NULL == CPlFunc) {
  69. #ifdef GMSHOW
  70. MessageBox(NULL,L"Failed to find dll export",NULL,MB_OK);
  71. #endif
  72. return FALSE;
  73. }
  74. return CPlFunc(hwndCPl,uMsg,lParam1,lParam2);
  75. break;
  76. case CPL_GETCOUNT:
  77. return 1; // only 1 applet icon in this cpl file
  78. break;
  79. case CPL_NEWINQUIRE:
  80. break;
  81. case CPL_INQUIRE:
  82. lpCPlInfo = (CPLINFO *) lParam2; // acquire ptr to target data
  83. lpCPlInfo->lData = 0; // no effect
  84. lpCPlInfo->idIcon = IDI_UPGRADE; // store items needed to show the applet
  85. lpCPlInfo->idName = IDS_APP_NAME;
  86. lpCPlInfo->idInfo = IDS_APP_DESCRIPTION; // description string
  87. break;
  88. case CPL_EXIT:
  89. FreeLibrary(hDll);
  90. break;
  91. // This will end up handling doubleclick and stop messages
  92. default:
  93. #ifdef GMSHOW
  94. MessageBox(NULL,L"Call to linked dll",NULL,MB_OK);
  95. #endif
  96. return CPlFunc(hwndCPl,uMsg,lParam1,lParam2);
  97. break;
  98. }
  99. return 0;
  100. }