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.

68 lines
1.7 KiB

  1. /**************************************************************************
  2. *
  3. * Copyright (c) 2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * Helper for GDI+ initialization
  8. *
  9. * Abstract:
  10. *
  11. * This code initializes GDI+ (with default parameters).
  12. * The code is probably specific to our compiler, because it uses #pragma to
  13. * get our code to be initialized before the app's other global objects.
  14. * The ordering is important when apps make global GDI+ objects.
  15. *
  16. * Notes:
  17. *
  18. * An app should check gGdiplusInitHelper.IsValid() in its main function,
  19. * and abort if it returns FALSE.
  20. *
  21. * Created:
  22. *
  23. * 09/18/2000 agodfrey
  24. * Created it.
  25. *
  26. **************************************************************************/
  27. #include <objbase.h>
  28. #include "gdiplus.h"
  29. #include "gpinit.h"
  30. GdiplusInitHelper::GdiplusInitHelper() : gpToken(0), Valid(FALSE)
  31. {
  32. Gdiplus::GdiplusStartupInput sti;
  33. if (Gdiplus::GdiplusStartup(&gpToken, &sti, NULL) == Gdiplus::Ok)
  34. {
  35. Valid = TRUE;
  36. }
  37. }
  38. GdiplusInitHelper::~GdiplusInitHelper()
  39. {
  40. if (Valid)
  41. {
  42. Gdiplus::GdiplusShutdown(gpToken);
  43. }
  44. }
  45. // Disable the stupid warning that says we have a "lib" code segment.
  46. #pragma warning( push )
  47. #pragma warning( disable : 4073 )
  48. // Make a separate code segment, and mark it as a "library initialization"
  49. // segment
  50. #pragma code_seg( "GpInit" )
  51. #pragma init_seg( lib )
  52. // Declare the global in this code segment, so that it is initialized before/
  53. // destroyed after the app's globals.
  54. GdiplusInitHelper gGdiplusInitHelper;
  55. // Reset the code segment to "whatever it was when compilation began".
  56. #pragma code_seg()
  57. #pragma warning( pop )