Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ::CreateDC() returns NULL with errorcode ERROR_INVALID_PRINTER_NAME(1801)

::CreateDC() returns NULL with errorcode ERROR_INVALID_PRINTER_NAME(1801)

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
12 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hanq_38910130
    wrote on last edited by
    #1

    Hi guys, I have a "display driver" program which I install it successfully on all kinds of OS. Then I call "::CreateDC()" to create a corresponding device context in another program, it works fine in most OS except in win2K. I mean, "::CreateDC()" succeeds in "XP, Vista, Win7", but fails in "Win2K"(returns NULL and GetLastError() is ERROR_INVALID_PRINTER_NAME(1801)). I googled it and did find some threads, but all are vague. However, I figure it's kinda "win2k OS" issue. I think function implementation of "CreateDC" in "win2k" has imperfection. Does anyone happen to encounter this same problem? Any workaround with it? Any replys are appreciated :-D

    E 1 Reply Last reply
    0
    • H hanq_38910130

      Hi guys, I have a "display driver" program which I install it successfully on all kinds of OS. Then I call "::CreateDC()" to create a corresponding device context in another program, it works fine in most OS except in win2K. I mean, "::CreateDC()" succeeds in "XP, Vista, Win7", but fails in "Win2K"(returns NULL and GetLastError() is ERROR_INVALID_PRINTER_NAME(1801)). I googled it and did find some threads, but all are vague. However, I figure it's kinda "win2k OS" issue. I think function implementation of "CreateDC" in "win2k" has imperfection. Does anyone happen to encounter this same problem? Any workaround with it? Any replys are appreciated :-D

      E Offline
      E Offline
      Eugen Podsypalnikov
      wrote on last edited by
      #2

      You could try to use the DC returned by PrintDlgEx(..)... :)

      virtual void BeHappy() = 0;

      H 1 Reply Last reply
      0
      • E Eugen Podsypalnikov

        You could try to use the DC returned by PrintDlgEx(..)... :)

        virtual void BeHappy() = 0;

        H Offline
        H Offline
        hanq_38910130
        wrote on last edited by
        #3

        Thanks for your reply :) But I think you misunderstood it. It has nothing to do with "Print" or "Printer". It's about "video display driver" :-D

        E 1 Reply Last reply
        0
        • H hanq_38910130

          Thanks for your reply :) But I think you misunderstood it. It has nothing to do with "Print" or "Printer". It's about "video display driver" :-D

          E Offline
          E Offline
          Eugen Podsypalnikov
          wrote on last edited by
          #4

          Yes, I have probably misunderstood it... :) ...does your call look like ::CreateDC("DISPLAY", NULL, ...); under W2K ? :)

          virtual void BeHappy() = 0;

          H 1 Reply Last reply
          0
          • E Eugen Podsypalnikov

            Yes, I have probably misunderstood it... :) ...does your call look like ::CreateDC("DISPLAY", NULL, ...); under W2K ? :)

            virtual void BeHappy() = 0;

            H Offline
            H Offline
            hanq_38910130
            wrote on last edited by
            #5

            ;) The follow is my code fragment: HDC CreateDCFromDriver() { HDC hDC; char lpszDriver[0x20]; if ( FALSE == GetDriverDeviceName(lpszDriver) ) return NULL; hDC = ::CreateDCA(lpszDriver, 0, 0, 0); if ( hDC == NULL ) { MM_TRACE(_T("CreateDCFromDriver: ErrorCode - %08X"), GetLastError()); } return hDC; } I think my code is just OK, cause everything works fine in "xp, vista, win7" OS. It only occur in "win2k", when in "win2k" OS the code will go into "MM_TRACE(_T("CreateDCFromDriver: ErrorCode - %08X"), GetLastError()); ". Meanwhile in other OS, it go into "return hDC;" correctly.

            E 1 Reply Last reply
            0
            • H hanq_38910130

              ;) The follow is my code fragment: HDC CreateDCFromDriver() { HDC hDC; char lpszDriver[0x20]; if ( FALSE == GetDriverDeviceName(lpszDriver) ) return NULL; hDC = ::CreateDCA(lpszDriver, 0, 0, 0); if ( hDC == NULL ) { MM_TRACE(_T("CreateDCFromDriver: ErrorCode - %08X"), GetLastError()); } return hDC; } I think my code is just OK, cause everything works fine in "xp, vista, win7" OS. It only occur in "win2k", when in "win2k" OS the code will go into "MM_TRACE(_T("CreateDCFromDriver: ErrorCode - %08X"), GetLastError()); ". Meanwhile in other OS, it go into "return hDC;" correctly.

              E Offline
              E Offline
              Eugen Podsypalnikov
              wrote on last edited by
              #6

              You could try to trace the lpszDriver too... :)

              virtual void BeHappy() = 0;

              H 1 Reply Last reply
              0
              • E Eugen Podsypalnikov

                You could try to trace the lpszDriver too... :)

                virtual void BeHappy() = 0;

                H Offline
                H Offline
                hanq_38910130
                wrote on last edited by
                #7

                :) Yes, I've tried that, and it's like "\\.\DISPLAY3" which is OK. I still believe that this problem is caused by the implementation of function "CreateDC" under "win2k" OS. ;P I just want to know if there's a workaround out there about this issue. :((

                E 1 Reply Last reply
                0
                • H hanq_38910130

                  :) Yes, I've tried that, and it's like "\\.\DISPLAY3" which is OK. I still believe that this problem is caused by the implementation of function "CreateDC" under "win2k" OS. ;P I just want to know if there's a workaround out there about this issue. :((

                  E Offline
                  E Offline
                  Eugen Podsypalnikov
                  wrote on last edited by
                  #8

                  Would it be enough under win2k ? :) :

                  MSDN:

                  If there are multiple monitors on the system, calling CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL) will create a DC covering all the monitors.

                  virtual void BeHappy() = 0;

                  H 2 Replies Last reply
                  0
                  • E Eugen Podsypalnikov

                    Would it be enough under win2k ? :) :

                    MSDN:

                    If there are multiple monitors on the system, calling CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL) will create a DC covering all the monitors.

                    virtual void BeHappy() = 0;

                    H Offline
                    H Offline
                    hanq_38910130
                    wrote on last edited by
                    #9

                    I do believe that it's relevant to multiple monitors, but I just can't ask our users to set up another monitor or another video card, or something like that. I can only make some improvement in our program which I still don't know how to do it. ;P

                    E 1 Reply Last reply
                    0
                    • E Eugen Podsypalnikov

                      Would it be enough under win2k ? :) :

                      MSDN:

                      If there are multiple monitors on the system, calling CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL) will create a DC covering all the monitors.

                      virtual void BeHappy() = 0;

                      H Offline
                      H Offline
                      hanq_38910130
                      wrote on last edited by
                      #10

                      Anyway, I really appreciate your help. ;P

                      1 Reply Last reply
                      0
                      • H hanq_38910130

                        I do believe that it's relevant to multiple monitors, but I just can't ask our users to set up another monitor or another video card, or something like that. I can only make some improvement in our program which I still don't know how to do it. ;P

                        E Offline
                        E Offline
                        Eugen Podsypalnikov
                        wrote on last edited by
                        #11

                        Probably the function can not understand the driver name under Win2k and try to find a printer with the name pointer NULL... :)

                        virtual void BeHappy() = 0;

                        modified on Tuesday, March 30, 2010 4:58 AM

                        H 1 Reply Last reply
                        0
                        • E Eugen Podsypalnikov

                          Probably the function can not understand the driver name under Win2k and try to find a printer with the name pointer NULL... :)

                          virtual void BeHappy() = 0;

                          modified on Tuesday, March 30, 2010 4:58 AM

                          H Offline
                          H Offline
                          hanq_38910130
                          wrote on last edited by
                          #12

                          Yes, I agree with your point. I found something on the internet which says it may be: * concerning issues about "video card", like "dualhead cards that use a single chipset" * or some "security risk" after win2k OS But for me, neither seems to be correct :(

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups