勇芳软件工作室.汉化:  GDI+ Reference > Functions >

GdiplusStartup Function

Previous pageReturn to chapter overviewNext page

描述

 

GdiplusStartup功能初始化Microsoft Windows GDI +。在进行任何其他GDI +呼叫之前,请调用GdiplusStartup,并在完成使用GDI +后致电GdiplusShutdown.

 

C++ 语法

 

Status GdiplusStartup(

ULONG_PTR token?token,

const GdiplusStartupInput?input,

GdiplusStartupOutput?output

);

 

PowerBASIC 语法

 

FUNCTION GdiplusStartup ( _

BYREF token AS DWORD _

BYREF pinput AS GdiplusStartupInput _

BYREF poutput AS GdiplusStartupOutput _

) AS LONG

 

参数

 

token

 

[out]指向接收令牌的ULONG_PTR的指针。完成使用GDI +后,将令牌传递给GdiplusShutdown.

 

input

 

[in]指向包含GDI +版本的GdiplusStartupInput结构的指针,指向调试回调函数的指针,指定是否禁止后台线程的布尔值以及指定是否禁止外部图像编解码器的布尔值。

 

output

 

[out]指向GdiplusStartupOutput结构的指针,该结构接收到通知挂钩函数的指针和指向通知未挂钩函数的指针。如果输入参数的SuppressBackgroundThread数据成员为FALSE,则该参数可以为NULL。

 

返回值

 

如果函数成功,则返回Ok,它是状态枚举的一个元素。

 

如果函数失败,它返回状态枚举的其他元素之一。

 

备注

 

在创建任何GDI +对象之前,您必须调用GdiplusStartup,然后在调用GdiplusShutdown之前必须先删除所有的GDI +对象。

 

只要您在致电GdiplusShutdown之前删除所有的GDI +对象(或超出范围),您可以在一个线程上调用GdiplusShutdown并调用另一个线程的GdiplusShutdown.

 

不要在LibMainLibMain调用的任何函数中调用GdiplusStartupGdiplusShutdown.如果要创建使用GDI +的动态链接库(DLL),您应该使用以下技术之一来初始化GDI +:

 

·要求您的客户端在调用DLL中的函数之前调用GdiplusStartup,并在完成使用DLL后调用GdiplusShutdown.
·导出您自己的启动函数调用GdiplusStartup和您自己的关闭功能调用GdiplusShutdown.要求您的客户端在调用您的启动函数之前调用其中的DLL函数,并在完成使用DLL后调用关机功能。
·在您进行GDI +呼叫的每个功能中调用GdiplusStartupGdiplusShutdown.

 

 

以下控制台应用程序使用GDI + Image对象来检索JPEG图像的宽度和高度。在创建Image对象之前,代码调用GdiplusStartup,并在终止前调用GdiplusShutdown.请注意,在调用GdiplusShutdown之前,将删除Image对象。

 

#COMPILE CON

#DIM ALL

#INCLUDE ONCE "gdiplus.inc"

 

FUNCTION PBMAIN () AS LONG

 

  LOCAL hStatus AS LONG

  LOCAL token AS DWORD

  LOCAL StartupInput AS GdiplusStartupInput

 

  StartupInput.GdiplusVersion = 1

  hStatus = GdiplusStartup(token, StartupInput, BYVAL %NULL)

 

  LOCAL pImage AS DWORD

  pImage = GdipLoadImageFromFile("FakePhoto.jpg", pImage)

  LOCAL nWidth AS LONG

  hStatus = GdipGetImageWidth(pImage, nWidth)

  PRINT "The width of the image is ", nWidth

  LOCAL nHeight AS LONG

  hStatus = GdipGetImageHeight(pImage, nHeight)

  PRINT "The height of the image is ", nHeight

 

  GdipDisposeImage pImage

  GdiplusShutdown token

 

END FUNCTION