如何判断系统安装了打印机并连接成功即可进行打印?

解决方案 »

  1.   

    GetPrinter
    The GetPrinter function retrieves information about a specified printer. BOOL GetPrinter(
      HANDLE hPrinter,    // handle to printer
      DWORD Level,        // information level
      LPBYTE pPrinter,    // printer information buffer
      DWORD cbBuf,        // size of buffer
      LPDWORD pcbNeeded   // bytes received or required
    );
    Return Values
    If the function succeeds, the return value is a nonzero value.If the function fails, the return value is zero. To get extended error information, call GetLastError. 
      

  2.   

    BOOL EnumPrintProcessors(
      LPTSTR pName,                // print server name
      LPTSTR pEnvironment,         // environment name
      DWORD Level,                 // information level
      LPBYTE pPrintProcessorInfo,  // processor data buffer
      DWORD cbBuf,                 // size of data buffer
      LPDWORD pcbNeeded,           // bytes received or required
      LPDWORD pcReturned           // number of processors
    );
    The EnumPrintProcessors function enumerates the print processors installed on the specified server. 
    可以利用此函数搜索打印机,而AddPrinter可以安装打印机。