Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

ExtEscape (gdi32)
 
.
Summary

C# Signature:

[DllImport("gdi32.dll")]
static extern int ExtEscape(IntPtr hdc, int nEscape, int cbInput,
   string lpszInData, int cbOutput, IntPtr lpszOutData);

VB.NET Signature:

     <DllImport("gdi32.dll")> _
    Public Shared Function ExtEscape(ByVal hdc As IntPtr, ByVal nEscape As Integer, ByVal cbInput As Integer, ByVal lpszInData As String, ByVal cbOutput As Integer, ByRef lpszOutData As IntPtr) As Integer
    End Function

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

           //By Justin Alexander, aka TheLoneCabbage

        static Int32 GETTECHNOLOGY = 20;
        static Int32 QUERYESCSUPPORT = 8;
        static Int32 POSTSCRIPT_PASSTHROUGH     =     4115;
        static Int32 ENCAPSULATED_POSTSCRIPT= 4116;

        static Int32 POSTSCRIPT_IDENTIFY    =     4117;
        static Int32 POSTSCRIPT_INJECTION       =     4118;
        static Int32 POSTSCRIPT_DATA        =     37;
        static Int32 POSTSCRIPT_IGNORE      =     38;

        static bool PrinterSupportsPostScript(string printername)
        {
            ArrayList PSChecks=new ArrayList();
            PSChecks.Add(POSTSCRIPT_PASSTHROUGH);
            PSChecks.Add(ENCAPSULATED_POSTSCRIPT);
            PSChecks.Add(POSTSCRIPT_IDENTIFY);
            PSChecks.Add(POSTSCRIPT_INJECTION);
            PSChecks.Add(POSTSCRIPT_DATA);
            PSChecks.Add(POSTSCRIPT_IGNORE);

            IntPtr hDC=IntPtr.Zero;;
            IntPtr BLOB=IntPtr.Zero;

            try
            {
                hDC =CreateDC(null,printername,0,IntPtr.Zero);

              SetLastError(true);

                int isz=4;
                BLOB = Marshal.AllocCoTaskMem(isz);
                Marshal.WriteInt32(BLOB,GETTECHNOLOGY);

                int test=ExtEscape( hDC, QUERYESCSUPPORT, 4, BLOB, 0, IntPtr.Zero);
                if(test==0) return false; // printer driver does not support GETTECHNOLOGY Checks.

                foreach(Int32 val in PSChecks)
                {
                    Marshal.WriteInt32(BLOB,val);
                    test = ExtEscape(hDC,QUERYESCSUPPORT,isz,BLOB,0, IntPtr.Zero);
                    if(test!=0) return true; // if any of the checks pass, return true
                }
            }
            catch(Exception ex){Trace.WriteLine(ex);}
            finally
            try
            {
                if(hDC!=IntPtr.Zero) DeleteDC(hDC);

                if(BLOB!=IntPtr.Zero) Marshal.Release(BLOB);
            };
                hDC =CreateDC(null,printername,0,IntPtr.Zero);

            return false;
                int isz=4;
                BLOB = Marshal.AllocCoTaskMem(isz);
                Marshal.WriteInt32(BLOB,GETTECHNOLOGY);

                int test=ExtEscape( hDC, QUERYESCSUPPORT, 4, BLOB, 0, IntPtr.Zero);
                if(test==0) return false; // printer driver does not support GETTECHNOLOGY Checks.

        }
                foreach(Int32 val in PSChecks)
                {
                    Marshal.WriteInt32(BLOB,val);
                    test = ExtEscape(hDC,QUERYESCSUPPORT,isz,BLOB,0, IntPtr.Zero);
                    if(test!=0) return true; // if any of the checks pass, return true
                }
            }
            catch(Exception ex){Trace.WriteLine(ex);}
            finally
            {
                if(hDC!=IntPtr.Zero) DeleteDC(hDC);

                if(BLOB!=IntPtr.Zero) Marshal.Release(BLOB);
            };

            return false;

Alternative Managed API:

Do you know one? Please contribute it!

        }

Documentation
ExtEscape on MSDN

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
ExtEscape on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions