代码之家  ›  专栏  ›  技术社区  ›  Tobias

如何使用CUPS在C++中获取网络中的打印机?

  •  1
  • Tobias  · 技术社区  · 1 年前

    CUPS现在似乎需要http_t*http;cupsGetDests(&dests)中的变量;方法,现在我不知道该怎么办,因为我还没有在网上找到任何参考资料。

    我已经做了一些搜索,得到了一些代码:

    #include "assets/cups/cups.h"
    #include <iostream>
    
    void list_printers(){
        cups_dest_t* dests;
        int num_dests = cupsGetDests(&dests);
       
        for(int i=0; i<num_dests; i++){
            std::cout << dests[i].name << endl;
        }
    }
    

    但这段代码在cupsGetDests()方法中不包括http变量,我也找不到任何其他具有此功能的代码片段。谢谢

    1 回复  |  直到 1 年前
        1
  •  0
  •   Sam Varshavchik    1 年前

    如中所述 CUPS Programming Manual :

      int cupsGetDests2(http_t *http, cups_dest_t **dests);                        
                                                                                    
        Parameters                                                                  
                                                                                    
       http  Connection to server or CUPS_HTTP_DEFAULT                              
       dests Destinations                                                           
    

    您想使用 cupsGetDests2 功能:

    auto n_dests=cupsGetDests2(CUPS_HTTP_DEFAULT, &dests);