GdiplusStartup

GdiplusStartup(token, input, output)

The GdiplusStartup function initializes GDI+. Call GdiplusStartup before making any other GDI+ calls, and call GdiplusShutdown when you have finished using GDI+.

Status GdiplusStartup(
  ULONG_PTR* token,
  const GdiplusStartupInput* input,
  GdiplusStartupOutput* output
);
Parameters
token
[out] Pointer to a ULONG_PTR that receives a token. Pass the token to GdiplusShutdown when you have finished using GDI+.
input
[in] Pointer to a GdiplusStartupInput structure that contains the GDI+ version, a pointer to a debug callback function, a Boolean value that specifies whether to suppress the background thread, and a Boolean value that specifies whether to suppress external image codecs.
output
[out] Pointer to a GdiplusStartupOutput structure that receives a pointer to a notification hook function and a pointer to a notification unhook function. If the SuppressBackgroundThread data member of the input parameter is FALSE, then this parameter can be NULL.
Return Values

If the function succeeds, it returns Ok, which is an element of the Status enumeration.

If the function fails, it returns one of the other elements of the Status enumeration.

Remarks

You must call GdiplusStartup before you create any GDI+ objects, and you must delete all of your GDI+ objects (or have them go out of scope) before you call GdiplusShutdown.

You can call GdiplusStartup on one thread and call GdiplusShutdown on another thread as long as you delete all of your GDI+ objects (or have them go out of scope) before you call GdiplusShutdown.

Do not call GdiplusStartup or GdiplusShutdown in DllMain or in any function that is called by DllMain. If you want to create a DLL that uses GDI+, you should use one of the following techniques to initialize GDI+:

  • Require your clients to call GdiplusStartup before they call the functions in your DLL and to call GdiplusShutdown when they have finished using your DLL.
  • Export your own startup function that calls GdiplusStartup and your own shutdown function that calls GdiplusShutdown. Require your clients to call your startup function before they call other functions in your DLL and to call your shutdown function when they have finished using your DLL.
  • Call GdiplusStartup and GdiplusShutdown in each of your functions that make GDI+ calls.
Example Code [C++]

For an example of calling GdiplusStartup and GdiplusShutdown in a Windows application, see Getting Started.

The following console application uses a GDI+ Image object to retrieve the width and height of a JPEG image. The code calls GdiplusStartup before creating the Image object and calls GdiplusShutdown before terminating. Note that the Image object is deleted before the call to GdiplusShutdown.

In the following code, the variable gdiplusStartupInput is initialized by the default constructor of the GdiplusStartupInput structure. The default constructor sets the data members of the structure to the following values:

  • GdiplusVersion = 1
  • DebugEventCallback = NULL
  • SuppressBackgroundThread = FALSE
  • SuppressExternalCodecs = FALSE
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;

INT main()
{
   GdiplusStartupInput gdiplusStartupInput;
   ULONG_PTR gdiplusToken;
   GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

   Image* image = new Image(L"FakePhoto.jpg");
   printf("The width of the image is %u./n", image->GetWidth());
   printf("The height of the image is %u./n", image->GetHeight()); 

   delete image;
   GdiplusShutdown(gdiplusToken);
   return 0;
}
Requirements

  Windows NT/2000/XP: Included in Windows XP and Windows .NET Server.
  Redistributable: Requires GDI+ on Windows NT 4.0 SP6; Windows 2000; and Windows 98/Me.
  Header: Declared in Gdiplusinit.h; include Gdiplus.h.
  Library: Use Gdiplus.lib. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值