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.

193 lines
5.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: C P L . C P P
  7. //
  8. // Contents: Entrypoints and other code for the new NCPA
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 12 Jan 1998
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "cplres.h"
  18. #include <openfold.h> // For launching connections folder
  19. #include <cpl.h>
  20. //---[ Globals ]--------------------------------------------------------------
  21. HINSTANCE g_hInst = NULL;
  22. //+---------------------------------------------------------------------------
  23. //
  24. // Function: DllMain
  25. //
  26. // Purpose: Standard DLL entrypoint
  27. //
  28. // Arguments:
  29. // hInstance [] Our instance handle
  30. // dwReason [] reason for invocation (attach/detach/etc)
  31. // lpReserved [] Unused
  32. //
  33. // Returns:
  34. //
  35. // Author: jeffspr 12 Jan 1998
  36. //
  37. // Notes:
  38. //
  39. BOOL APIENTRY DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved )
  40. {
  41. g_hInst = hInstance;
  42. if (dwReason == DLL_PROCESS_ATTACH)
  43. {
  44. InitializeDebugging();
  45. if (FIsDebugFlagSet (dfidNetShellBreakOnInit))
  46. {
  47. DebugBreak();
  48. }
  49. DisableThreadLibraryCalls(hInstance);
  50. }
  51. else if (dwReason == DLL_PROCESS_DETACH)
  52. {
  53. UnInitializeDebugging();
  54. }
  55. return TRUE;
  56. }
  57. //+---------------------------------------------------------------------------
  58. //
  59. // Function: CPlApplet
  60. //
  61. // Purpose:
  62. //
  63. // Arguments:
  64. // hwndCPL [in] Handle of control panel window
  65. // uMsg [in] message
  66. // lParam1 [in]
  67. // lParam2 [in]
  68. //
  69. // Returns:
  70. //
  71. // Author: jeffspr 12 Jan 1998
  72. //
  73. // Notes:
  74. //
  75. LONG CALLBACK CPlApplet( HWND hwndCPL, UINT uMsg, LPARAM lParam1, LPARAM lParam2 )
  76. {
  77. TraceFileFunc(ttidShellFolder);
  78. LPNEWCPLINFO pNewCPlInfo = NULL;
  79. LPCPLINFO pCPlInfo = NULL;
  80. INT iApp = NULL;
  81. LONG lReturn = 0;
  82. iApp = ( int ) lParam1;
  83. switch ( uMsg )
  84. {
  85. // First message, sent once.
  86. //
  87. case CPL_INIT:
  88. TraceTag(ttidShellFolder, "NCPA message: CPL_INIT");
  89. lReturn = 1; // Successfully initialized
  90. break;
  91. // Second message, sent once.
  92. //
  93. case CPL_GETCOUNT:
  94. TraceTag(ttidShellFolder, "NCPA message: CPL_GETCOUNT");
  95. lReturn = 1; // We only have one app to support
  96. break;
  97. // Third message (alternate, old). Sent once per app
  98. //
  99. case CPL_INQUIRE:
  100. TraceTag(ttidShellFolder, "NCPA message: CPL_INQUIRE");
  101. pCPlInfo = ( LPCPLINFO ) lParam2;
  102. pCPlInfo->idIcon = IDI_NCPA;
  103. pCPlInfo->idName = IDS_NCPTITLE;
  104. pCPlInfo->idInfo = IDS_NCPDESC;
  105. pCPlInfo->lData = NULL;
  106. lReturn = 0; // Processed successfully
  107. break;
  108. // Alternate third message, sent once per app
  109. //
  110. case CPL_NEWINQUIRE:
  111. TraceTag(ttidShellFolder, "NCPA message: CPL_NEWINQUIRE");
  112. lReturn = 1; // Ignore this message
  113. break;
  114. // Application icon selected. We should never get this message
  115. //
  116. case CPL_SELECT:
  117. TraceTag(ttidShellFolder, "NCPA message: CPL_SELECT");
  118. lReturn = 1; // Who cares? We never get this.
  119. break;
  120. // Application icon double-clicked.
  121. // Or application invoked via STARTWPARAMS (through rundll)
  122. //
  123. case CPL_DBLCLK:
  124. case CPL_STARTWPARMSW:
  125. case CPL_STARTWPARMSA:
  126. switch(uMsg)
  127. {
  128. case CPL_STARTWPARMSW:
  129. TraceTag(ttidShellFolder, "NCPA message: CPL_STARTWPARMSW, app: %d, parms: %S",
  130. lParam1, lParam2 ? (PWSTR) lParam2 : L"");
  131. break;
  132. case CPL_STARTWPARMSA:
  133. TraceTag(ttidShellFolder, "NCPA message: CPL_STARTWPARMSA, app: %d, parms: %s",
  134. lParam1, lParam2 ? (PSTR) lParam2 : "");
  135. break;
  136. case CPL_DBLCLK:
  137. TraceTag(ttidShellFolder, "NCPA message: CPL_DBLCLK");
  138. break;
  139. }
  140. // No matter what, we're doing the same thing here
  141. //
  142. (VOID) HrOpenConnectionsFolder();
  143. // Return the correct code. DBLCLK wants 0 == success, the others want (TRUE)
  144. //
  145. if (uMsg == CPL_DBLCLK)
  146. lReturn = 0; // Processed successfully
  147. else
  148. lReturn = 1; // TRUE, which for the START versions means success
  149. break;
  150. // Controlling application closing.
  151. //
  152. case CPL_STOP:
  153. TraceTag(ttidShellFolder, "NCPA message: CPL_STOP");
  154. lReturn = 0; // Processed succesfully
  155. break;
  156. // We're about to be released. Sent after last CPL_STOP
  157. //
  158. case CPL_EXIT:
  159. TraceTag(ttidShellFolder, "NCPA message: CPL_EXIT");
  160. lReturn = 0; // Processed successfully
  161. break;
  162. default:
  163. TraceTag(ttidShellFolder, "NCPA message: CPL_? (%d)", uMsg);
  164. lReturn = 1;
  165. break;
  166. }
  167. return lReturn;
  168. }