如题。我遇到的情况:我写的打印程序在网络打印机上出现问题,假如你的网络没有启动此时你打印程序就会发生错误然后重启或者该进程死去。

解决方案 »

  1.   

    BOOL OpenPrinter(
      LPTSTR pPrinterName,         // printer or server name
      LPHANDLE phPrinter,          // printer or server handle
      LPPRINTER_DEFAULTS pDefault  // printer defaults
    );
    来判断是否能打开打印机?
      

  2.   

    楼上的已经说了
    BOOL EnumPrinters(
      DWORD Flags,         // types of printer objects to enumerate
      LPTSTR Name,         // name of printer object
      DWORD Level,         // specifies type of printer info structure
      LPBYTE pPrinterEnum, // pointer to buffer to receive printer info 
                           // structures
      DWORD cbBuf,         // size, in bytes, of the buffer
      LPDWORD pcbNeeded,   // pointer to variable with no. of bytes 
                           // copied (or required)
      LPDWORD pcReturned   // pointer to variable with no. of printer 
                           // info. structures copied
    );
    用来查询打印机