Consultor Eletrônico



Kbase 17354: How to Call WIN32 API Function: DeleteDC
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
How to Call WIN32 API Function: DeleteDC

DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.

INTRODUCTION:
=============
The following sample code shows how to call the Win32 API function
called DeleteDC. This function deletes the given device context (DC).
An application must not delete a DC that was retrieved with GetDC().
Instead, it must use the ReleaseDC() function.

This code has been tested on Windows NT 4.0 Workstation only.


DEFINE VARIABLE intDC AS INTEGER NO-UNDO. /* Printer Device Context */
DEFINE VARIABLE intRC AS INTEGER NO-UNDO.

PROCEDURE CreateDCA EXTERNAL "GDI32.DLL":
DEFINE INPUT PARAMETER lpszDriver AS CHARACTER.
DEFINE INPUT PARAMETER lpszDevice AS CHARACTER.
DEFINE INPUT PARAMETER lpszOutput AS LONG.
DEFINE INPUT PARAMETER lpInitData AS LONG.
DEFINE RETURN PARAMETER intRC AS LONG.
END PROCEDURE.

PROCEDURE DeleteDC EXTERNAL "GDI32.DLL":
DEFINE INPUT PARAMETER hdc AS LONG.
DEFINE RETURN PARAMETER intRC AS LONG.
END PROCEDURE.

RUN CreateDCA ("WINSPOOL", "\\TECHSUPP\LWMIS", 0, 0, OUTPUT intDC).

IF intDC = 0 THEN
MESSAGE "CreateDC Failed" VIEW-AS ALERT-BOX.
ELSE
DO:
MESSAGE "CreateDC Worked" VIEW-AS ALERT-BOX.
RUN DeleteDC (intDC, OUTPUT intRC).
IF intRC <> 0 THEN
MESSAGE "DeleteDC Worked" VIEW-AS ALERT-BOX.
ELSE
MESSAGE "DeleteDC Failed" VIEW-AS ALERT-BOX.
END.

Progress Software Technical Support Note # 17354