🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13266

Re: how to detect if a printer a postscript printer in c++

#13266
From: Richard Yu
Date: Fri, 17 Oct 2003 17:35
78 lines
3583 bytes
for my win 2000, I use PrintDLgEx,
the code like :

        HRESULT hResult;
        LPPRINTDLGEX pPDX = NULL;
        LPPRINTPAGERANGE pPageRanges = NULL;
        DEVMODE *dv;
        int nEscapeCode;
        TCHAR szTechnology[MAX_PATH] = TEXT("");

        pPDX = (LPPRINTDLGEX)GlobalAlloc(GPTR, sizeof(PRINTDLGEX));
        if (!pPDX)
        {
        //
        }

        pPageRanges = (LPPRINTPAGERANGE) GlobalAlloc(GPTR,
                          10 * sizeof(PRINTPAGERANGE));
        if (!pPageRanges)
        {
        //
        }

        pPDX->lStructSize = sizeof(PRINTDLGEX);
        pPDX->hwndOwner = GetDesktopWindow();;//hWnd;
        pPDX->hDevMode = NULL;
        pPDX->hDevNames = NULL;
        pPDX->hDC = NULL;
        pPDX->Flags = PD_RETURNDC | PD_COLLATE;
        pPDX->Flags2 = 0;
        pPDX->ExclusionFlags = 0;
        pPDX->nPageRanges = 0;
        pPDX->nMaxPageRanges = 10;
        pPDX->lpPageRanges = pPageRanges;
        pPDX->nMinPage = 1;
        pPDX->nMaxPage = 1000;
        pPDX->nCopies = 1;
        pPDX->hInstance = 0;
        pPDX->lpPrintTemplateName = NULL;
        pPDX->lpCallback = NULL;
        pPDX->nPropertyPages = 0;
        pPDX->lphPropertyPages = NULL;
        pPDX->nStartPage = START_PAGE_GENERAL;
        pPDX->dwResultAction = 0;

        hResult = PrintDlgEx(pPDX);

        if(hResult==S_OK )
        {

           dv=(LPDEVMODE)pPDX->hDevMode;
           char** Name=(char**)dv->dmDeviceName;
           file://ShowMessage(AnsiString((const char*)*Name));
           Edit1->Text=AnsiString((const char*)*Name);
           nEscapeCode = POSTSCRIPT_PASSTHROUGH;
           if( ExtEscape( pPDX->hDC, QUERYESCSUPPORT, sizeof(int),
                (LPCSTR)&nEscapeCode, 0, NULL ) > 0 )
           {
                 ShowMessage("Escape POSTSCRIPT_PASSTHROUGH is supported" );
                     return;
           }
            ShowMessage("Escape POSTSCRIPT_PASSTHROUGH is not supported" );
             // If it doesn't support GETTECHNOLOGY, we won't be able to
tell.
             nEscapeCode = GETTECHNOLOGY;
             if( ExtEscape( pPDX->hDC, QUERYESCSUPPORT, sizeof(int),
                (LPCSTR)&nEscapeCode, 0, NULL ) <= 0 )
             {
                  ShowMessage("Escape GETTECHNOLOGY is not supported" );
file://reaches here and exit,
                     return;
             }
  }


in the printer dialg, I choose the only printer, a network PS printer
hp4500,  hResult is OK,  but still fail to detect my PS printer, returned at
the position mentioned.
Technical Details
Message-ID: <3f90289e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f8c71fd$1@newsgroups.borland.com> <3f8cfaf6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,3ac529bf9ac223f1
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-17 10:39:43 PST
From: "Richard Yu" <richard@colorselector.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References:  <3f8c71fd$1@newsgroups.borland.com> <3f8cfaf6$1@newsgroups.borland.com>
Subject: Re: how to detect if a printer a postscript printer in c++
Date: Fri, 17 Oct 2003 10:35:35 -0700
Lines: 80
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 24.207.7.224
Message-ID: <3f90289e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1066412190 24.207.7.224 (17 Oct 2003 10:36:30 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail