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.

62 lines
2.0 KiB

  1. // OLESTUFF.CPP
  2. // Implementation of OLE delay-loaded stuff. This is needed for the
  3. // classes defined in TBDROP.CPP and TABDROP.CPP.
  4. // More OLE stuff could go here in the future.
  5. // ==
  6. // Technically this code is not C++ however, both files that call us
  7. // are C++, and this is where we call for the C++ glue in crtfree.h.
  8. // So for now this remains a .CPP file.
  9. //
  10. // History:
  11. // 8/22/96 - t-mkim: created
  12. //
  13. #include "ctlspriv.h"
  14. #include "olestuff.h"
  15. // Allow C++ files to be linked in w/o error
  16. #define CPP_FUNCTIONS
  17. #include <crtfree.h>
  18. #define OLELIBNAME TEXT ("OLE32.DLL")
  19. // function pointers for GetProcAddress.
  20. typedef HRESULT (STDAPICALLTYPE *LPFNCOINITIALIZE)(LPMALLOC pMalloc);
  21. typedef void (STDAPICALLTYPE *LPFNCOUNINITIALIZE)(void);
  22. typedef HRESULT (STDAPICALLTYPE *LPFNREGISTERDRAGDROP)(HWND hwnd, LPDROPTARGET pDropTarget);
  23. typedef HRESULT (STDAPICALLTYPE *LPFNREVOKEDRAGDROP)(HWND hwnd);
  24. HMODULE PrivLoadOleLibrary ()
  25. {
  26. // We call GetModuleHandle first so we don't map the library if we don't
  27. // need to. We would like to avoid the overhead necessary to do so.
  28. return GetModuleHandle(OLELIBNAME) ? LoadLibrary (OLELIBNAME) : NULL;
  29. }
  30. BOOL PrivFreeOleLibrary(HMODULE hmodOle)
  31. {
  32. return FreeLibrary(hmodOle);
  33. }
  34. HRESULT PrivCoInitialize (HMODULE hmodOle)
  35. {
  36. LPFNCOINITIALIZE pfnCoInitialize = (LPFNCOINITIALIZE) GetProcAddress (hmodOle, "CoInitialize");
  37. return pfnCoInitialize (NULL);
  38. }
  39. void PrivCoUninitialize (HMODULE hmodOle)
  40. {
  41. LPFNCOUNINITIALIZE pfnCoUninitialize = (LPFNCOUNINITIALIZE) GetProcAddress (hmodOle, "CoUninitialize");
  42. pfnCoUninitialize ();
  43. }
  44. HRESULT PrivRegisterDragDrop (HMODULE hmodOle, HWND hwnd, IDropTarget *pDropTarget)
  45. {
  46. LPFNREGISTERDRAGDROP pfnRegisterDragDrop = (LPFNREGISTERDRAGDROP) GetProcAddress (hmodOle, "RegisterDragDrop");
  47. return pfnRegisterDragDrop(hwnd, pDropTarget);
  48. }
  49. HRESULT PrivRevokeDragDrop (HMODULE hmodOle, HWND hwnd)
  50. {
  51. LPFNREVOKEDRAGDROP pfnRevokeDragDrop = (LPFNREVOKEDRAGDROP) GetProcAddress (hmodOle, "RevokeDragDrop");
  52. return pfnRevokeDragDrop (hwnd);
  53. }