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.

189 lines
4.9 KiB

  1. #define _SHELL32_ 1 // we implement shell32 fn's
  2. #include <windows.h>
  3. #include <winnt.h>
  4. #include <shellapi.h>
  5. #include <shlobj.h>
  6. #include <shlobjp.h>
  7. #include <shlwapi.h>
  8. #include <shlwapip.h>
  9. // The following functions do NOT exist in NT4sp6's non-integrate shell32, so we implement them
  10. // here so that browseui and shdocvw can link to shell32.nt4 and this code lib (downlevel_shell32.lib)
  11. HMODULE DL_GetSHELL32()
  12. {
  13. static HMODULE hmod = (HMODULE)-1;
  14. if (hmod == (HMODULE)-1)
  15. {
  16. hmod = LoadLibraryA("shell32.dll");
  17. }
  18. return hmod;
  19. }
  20. typedef HRESULT (* PFNSHDefExtractIconA) (LPCSTR, int, UINT, HICON*, HICON*, UINT);
  21. STDAPI DL_SHDefExtractIconA(
  22. LPCSTR pszIconFile,
  23. int iIndex,
  24. UINT uFlags,
  25. HICON *phiconLarge,
  26. HICON *phiconSmall,
  27. UINT nIconSize
  28. )
  29. {
  30. if (WhichPlatform() == PLATFORM_INTEGRATED)
  31. {
  32. static PFNSHDefExtractIconA pfn = (PFNSHDefExtractIconA)-1;
  33. if (pfn == (PFNSHDefExtractIconA)-1)
  34. {
  35. pfn = (PFNSHDefExtractIconA)GetProcAddress(DL_GetSHELL32(), MAKEINTRESOURCEA(3));
  36. }
  37. if (pfn)
  38. {
  39. return pfn(pszIconFile, iIndex, uFlags, phiconLarge, phiconSmall, nIconSize);
  40. }
  41. }
  42. return HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND);
  43. }
  44. PFNSHDefExtractIconA g_pfnDL_SHDefExtractIconA = &DL_SHDefExtractIconA;
  45. typedef HRESULT (* PFNSHStartNetConnectionDialogW) (HWND, LPCWSTR, DWORD);
  46. STDAPI DL_SHStartNetConnectionDialogW(
  47. HWND hwnd,
  48. LPCWSTR pszRemoteName,
  49. DWORD dwType
  50. )
  51. {
  52. if (WhichPlatform() == PLATFORM_INTEGRATED)
  53. {
  54. static PFNSHStartNetConnectionDialogW pfn = (PFNSHStartNetConnectionDialogW)-1;
  55. if (pfn == (PFNSHStartNetConnectionDialogW)-1)
  56. {
  57. pfn = (PFNSHStartNetConnectionDialogW)GetProcAddress(DL_GetSHELL32(), MAKEINTRESOURCEA(14));
  58. }
  59. if (pfn)
  60. {
  61. return pfn(hwnd, pszRemoteName, dwType);
  62. }
  63. }
  64. return S_OK;
  65. }
  66. PFNSHStartNetConnectionDialogW g_pfnDL_SHStartNetConnectionDialogW = &DL_SHStartNetConnectionDialogW;
  67. typedef BOOL (* PFNDAD_DragEnterEx2) (HWND, const POINT, IDataObject*);
  68. STDAPI_(BOOL) DL_DAD_DragEnterEx2(
  69. HWND hwndTarget,
  70. const POINT ptStart,
  71. IDataObject* pdtObject
  72. )
  73. {
  74. // DAD_DragEnterEx2 only exists on v5 shell32 and higher
  75. if (GetUIVersion() >= 5)
  76. {
  77. static PFNDAD_DragEnterEx2 pfn = (PFNDAD_DragEnterEx2)-1;
  78. if (pfn == (PFNDAD_DragEnterEx2)-1)
  79. {
  80. pfn = (PFNDAD_DragEnterEx2)GetProcAddress(DL_GetSHELL32(), MAKEINTRESOURCEA(22));
  81. }
  82. if (pfn)
  83. {
  84. return pfn(hwndTarget, ptStart, pdtObject);
  85. }
  86. }
  87. // this exists on downlevel shell32, so we fall back to calling the older api
  88. return DAD_DragEnterEx(hwndTarget, ptStart);
  89. }
  90. PFNDAD_DragEnterEx2 g_pfnDL_DAD_DragEnterEx2 = &DL_DAD_DragEnterEx2;
  91. typedef void (* PFNSHUpdateImageW) (LPCWSTR, int, UINT, int);
  92. STDAPI_(void) DL_SHUpdateImageW(
  93. LPCWSTR pszHashItem,
  94. int iIndex,
  95. UINT uFlags,
  96. int iImageIndex
  97. )
  98. {
  99. if (WhichPlatform() == PLATFORM_INTEGRATED)
  100. {
  101. static PFNSHUpdateImageW pfn = (PFNSHUpdateImageW)-1;
  102. if (pfn == (PFNSHUpdateImageW)-1)
  103. {
  104. pfn = (PFNSHUpdateImageW)GetProcAddress(DL_GetSHELL32(), MAKEINTRESOURCEA(192));
  105. }
  106. if (pfn)
  107. {
  108. pfn(pszHashItem, iIndex, uFlags, iImageIndex);
  109. return;
  110. }
  111. }
  112. }
  113. PFNSHUpdateImageW g_pfnDL_SHUpdateImageW = &DL_SHUpdateImageW;
  114. typedef int (* PFNSHHandleUpdateImage) (LPCITEMIDLIST);
  115. STDAPI_(int) DL_SHHandleUpdateImage(
  116. LPCITEMIDLIST pidlExtra
  117. )
  118. {
  119. if (WhichPlatform() == PLATFORM_INTEGRATED)
  120. {
  121. static PFNSHHandleUpdateImage pfn = (PFNSHHandleUpdateImage)-1;
  122. if (pfn == (PFNSHHandleUpdateImage)-1)
  123. {
  124. pfn = (PFNSHHandleUpdateImage)GetProcAddress(DL_GetSHELL32(), MAKEINTRESOURCEA(193));
  125. }
  126. if (pfn)
  127. {
  128. return pfn(pidlExtra);
  129. }
  130. }
  131. return -1;
  132. }
  133. PFNSHHandleUpdateImage g_pfnDL_SHHandleUpdateImage = &DL_SHHandleUpdateImage;
  134. typedef HRESULT (* PFNSHLimitInputEdit) (HWND, IShellFolder*);
  135. STDAPI DL_SHLimitInputEdit(
  136. HWND hwndEdit,
  137. IShellFolder *psf
  138. )
  139. {
  140. if (WhichPlatform() == PLATFORM_INTEGRATED)
  141. {
  142. static PFNSHLimitInputEdit pfn = (PFNSHLimitInputEdit)-1;
  143. if (pfn == (PFNSHLimitInputEdit)-1)
  144. {
  145. pfn = (PFNSHLimitInputEdit)GetProcAddress(DL_GetSHELL32(), MAKEINTRESOURCEA(747));
  146. }
  147. if (pfn)
  148. {
  149. return pfn(hwndEdit, psf);
  150. }
  151. }
  152. return HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND);
  153. }
  154. PFNSHLimitInputEdit g_pfnDL_SHLimitInputEdit = DL_SHLimitInputEdit;