CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    10

    [RESOLVED] EnumPorts error

    I did a search and couldn't find any help. I am calling EnumPorts to get a list of network printers installed on the computer. When I call EnumPorts the first time (to find the buffer size) it returns 0 (fails) and GetLastError() gives : 1722 (RPC server is unavailable). Has anyone seen this before?

    I call EnumPorts in the install, but when I call the uninstall it gives this error.

    Further info: this is in a driver and being built with WDK 7100

    Code:
       DWORD needed(0);
       DWORD returned(0);
       DWORD status = ERROR_SUCCESS;
       DWORD err;
       SetLastError(ERROR_SUCCESS);
    
       BOOL brc = EnumPorts(NULL, 1, NULL, 0, &needed, &returned);
       err = GetLastError();//err = 1722 at this point
       PORT_INFO_1* port_into_1s = (PORT_INFO_1*) new BYTE[needed];
       brc = EnumPorts(NULL, 1, (PBYTE) port_into_1s, needed, &needed, &returned);
       err = GetLastError();  err = 1722 at this point

  2. #2
    Join Date
    Aug 2009
    Posts
    10

    Re: EnumPorts error

    Solved. Turns out I called EnumPorts() when we still had teh spooler turned off. Changed the call to after we restart the spooler and worked great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured