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.

126 lines
2.4 KiB

  1. /*++
  2. Contains DLLMain and standard OLE COM object creation stuff.
  3. --*/
  4. #include <windows.h>
  5. #include <objbase.h>
  6. #include <shlobj.h>
  7. #include <olectl.h> // Dll[Un]RegisterServer
  8. #include "classfac.h"
  9. #include "psexsup.h"
  10. #define DECL_CRTFREE
  11. #include <crtfree.h>
  12. // GUID stuff
  13. // this is only done once
  14. // TODO, see if this is appropriate
  15. #pragma data_seg(".text")
  16. #define INITGUID
  17. #include <initguid.h>
  18. #include <shlguid.h>
  19. #include "guid.h"
  20. #pragma data_seg()
  21. HINSTANCE g_hInst;
  22. LONG g_DllRefCount = 0;
  23. BOOL g_bShowIETB;
  24. BOOL g_bShowISTB;
  25. int g_nColumn1;
  26. int g_nColumn2;
  27. extern "C" BOOL WINAPI DllMain(
  28. HINSTANCE hInstance,
  29. DWORD dwReason,
  30. LPVOID lpReserved
  31. )
  32. {
  33. switch(dwReason)
  34. {
  35. case DLL_PROCESS_ATTACH:
  36. DisableThreadLibraryCalls(hInstance);
  37. g_hInst = hInstance;
  38. //
  39. // initialize Protected Storage Support routines
  40. //
  41. if(!InitializePStoreSupport())
  42. return FALSE;
  43. //
  44. // init common controls
  45. //
  46. INITCOMMONCONTROLSEX iccex;
  47. iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  48. iccex.dwICC = ICC_LISTVIEW_CLASSES;
  49. InitCommonControlsEx(&iccex);
  50. break;
  51. case DLL_PROCESS_DETACH:
  52. ShutdownPStoreSupport();
  53. break;
  54. }
  55. return TRUE;
  56. }
  57. STDAPI
  58. DllCanUnloadNow(
  59. void
  60. )
  61. {
  62. return (g_DllRefCount ? S_FALSE : S_OK);
  63. }
  64. STDAPI
  65. DllGetClassObject(
  66. REFCLSID rclsid,
  67. REFIID riid,
  68. LPVOID *ppReturn
  69. )
  70. {
  71. //
  72. // if we don't support this classid, return the proper error code
  73. //
  74. if(!IsEqualCLSID(rclsid, CLSID_PStoreNameSpace))
  75. return CLASS_E_CLASSNOTAVAILABLE;
  76. //
  77. // create a CClassFactory object and check it for validity
  78. //
  79. CClassFactory *pClassFactory = new CClassFactory();
  80. if(NULL == pClassFactory)
  81. return E_OUTOFMEMORY;
  82. //
  83. // get the QueryInterface return for our return value
  84. //
  85. HRESULT hResult = pClassFactory->QueryInterface(riid, ppReturn);
  86. //
  87. // call Release to decrement the ref count - creating the object set it to
  88. // one and QueryInterface incremented it - since its being used externally
  89. // (not by us), we only want the ref count to be 1
  90. //
  91. pClassFactory->Release();
  92. return hResult;
  93. }