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.

171 lines
4.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: O P E N F O L D . C P P
  7. //
  8. // Contents: Folder launching code for the connections folder
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 12 Jan 1998
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. // Undocument shell32 stuff. Sigh.
  18. #define DONT_WANT_SHELLDEBUG 1
  19. #define NO_SHIDLIST 1
  20. #define USE_SHLWAPI_IDLIST
  21. #include <commctrl.h>
  22. #include <ncdebug.h>
  23. #include <openfold.h> // For launching connections folder
  24. // Note -- Don't convert this to a constant. We need copies of it within the
  25. // functions because ParseDisplayName actually mangles the string.
  26. //
  27. // CLSID_MyComputer
  28. // CLSID_ControlPanel
  29. // CLSID_NetworkConnections
  30. #define NETCON_FOLDER_PATH L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\" \
  31. L"::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\" \
  32. L"::{7007ACC7-3202-11D1-AAD2-00805FC1270E}";
  33. //+---------------------------------------------------------------------------
  34. //
  35. // Function: HrGetConnectionsFolderPidl
  36. //
  37. // Purpose: Get the connections folder pidl. Used in places where we're
  38. // not folder specific, but we still need to update folder
  39. // entries.
  40. //
  41. // Arguments:
  42. // ppidlFolder [out] Return parameter for the folder pidl
  43. //
  44. // Returns:
  45. //
  46. // Author: jeffspr 13 Jun 1998
  47. //
  48. // Notes:
  49. //
  50. HRESULT HrGetConnectionsFolderPidl(LPITEMIDLIST *ppidlFolder)
  51. {
  52. HRESULT hr = S_OK;
  53. LPSHELLFOLDER pshf = NULL;
  54. LPITEMIDLIST pidlFolder = NULL;
  55. Assert(ppidlFolder);
  56. // "::CLSID_MyComputer\\::CLSID_ControlPanel\\::CLSID_ConnectionsFolder"
  57. WCHAR szNetConFoldPath[] = NETCON_FOLDER_PATH;
  58. // Get the desktop folder, so we can parse the display name and get
  59. // the UI object of the connections folder
  60. //
  61. hr = SHGetDesktopFolder(&pshf);
  62. if (SUCCEEDED(hr))
  63. {
  64. ULONG chEaten;
  65. hr = pshf->ParseDisplayName(NULL, 0, (WCHAR *) szNetConFoldPath,
  66. &chEaten, &pidlFolder, NULL);
  67. ReleaseObj(pshf);
  68. }
  69. // If succeeded, fill in the return param.
  70. //
  71. if (SUCCEEDED(hr))
  72. {
  73. *ppidlFolder = pidlFolder;
  74. }
  75. else
  76. {
  77. // If we failed, then delete the pidl if we already got it.
  78. //
  79. if (pidlFolder)
  80. SHFree(pidlFolder);
  81. }
  82. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrGetConnectionsFolderPidl");
  83. return hr;
  84. }
  85. //+---------------------------------------------------------------------------
  86. //
  87. // Function: HrOpenConnectionsFolder
  88. //
  89. // Purpose: Open the connections folder in explorer.
  90. //
  91. // Arguments:
  92. // (none)
  93. //
  94. // Returns:
  95. //
  96. // Author: jeffspr 16 Apr 1998
  97. //
  98. // Notes:
  99. //
  100. HRESULT HrOpenConnectionsFolder()
  101. {
  102. HRESULT hr = S_OK;
  103. HCURSOR hcWait = SetCursor(LoadCursor(NULL, IDC_WAIT));
  104. LPITEMIDLIST pidlFolder = NULL;;
  105. hr = HrGetConnectionsFolderPidl(&pidlFolder);
  106. if (SUCCEEDED(hr))
  107. {
  108. Assert(pidlFolder);
  109. SHELLEXECUTEINFO shei = { 0 };
  110. shei.cbSize = sizeof(shei);
  111. shei.fMask = SEE_MASK_IDLIST | SEE_MASK_INVOKEIDLIST | SEE_MASK_FLAG_DDEWAIT;
  112. shei.nShow = SW_SHOW; // used to be SW_SHOWNORMAL
  113. shei.lpIDList = pidlFolder;
  114. ShellExecuteEx(&shei);
  115. SHFree(pidlFolder);
  116. }
  117. if (hcWait)
  118. {
  119. SetCursor(hcWait);
  120. }
  121. TraceHr(ttidError, FAL, hr, FALSE, "HrOpenConnectionsFolder");
  122. return hr;
  123. }
  124. HRESULT HrGetConnectionsIShellFolder(
  125. LPITEMIDLIST pidlFolder,
  126. LPSHELLFOLDER * ppsf)
  127. {
  128. HRESULT hr = S_OK;
  129. LPSHELLFOLDER psfDesktop = NULL;
  130. Assert(ppsf);
  131. *ppsf = NULL;
  132. // Get the desktop folder so we can use it to retrieve the
  133. // connections folder
  134. //
  135. hr = SHGetDesktopFolder(&psfDesktop);
  136. if (SUCCEEDED(hr))
  137. {
  138. Assert(psfDesktop);
  139. hr = psfDesktop->BindToObject(pidlFolder, NULL, IID_IShellFolder,
  140. (LPVOID*) ppsf);
  141. }
  142. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrGetConnectionsIShellFolder");
  143. return hr;
  144. }