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.

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