我要做一个打印设置页面。
我要获得如下信息:
1。当前系统安装的打印机
2。当选中一个打印机的时候获得此打印机所支持的纸张类型。
3。当选种一种纸张类型后,获得此类型纸张的实际尺寸。
4。获得上述信息后,对上述信息如何设置。我使用 EnumPrinter 获得打印机不好使。看别人的帖子说98下使用EnumPrinter而2000下得使用函数 GetDefaultPrinter。但是我的 VC6.0的帮助中没有此函数的帮助。我装了VC6.0的sp5也没有此函数,而且 winspool.h中也没有此函数定义。我该怎么办?

解决方案 »

  1.   

    用DEVMODE结构体可以获取关于打印机的很多信息,比如打印机的类型,纸张类型等等!!
    DEVMODE结构体的具体用法msdn里有详细地介绍!
      

  2.   

    忘了说一句,这个结构体在98,nt,2000,xp下都能使用!
    :)
      

  3.   

    PRINTER_INFO_4(不只有4,还有5,1,2等查msdn最好不过)
    可以得到用::EnumPrinters来玫举
      

  4.   

    PRINTER_INFO_1,2,4,5什么的都是什么意思?我应该使那个?有没有具体的代码?我不会写啊。
      

  5.   

    这个要从打印机的驱动里获得!使用 DeviceIoControl,他是Ring3层的APP与Ring0层的驱动的接口。原型如下:
    The DeviceIoControl function sends a control code directly to a specified device driver, causing the corresponding device to perform the specified operation. BOOL DeviceIoControl(    HANDLE hDevice, // handle to device of interest
        DWORD dwIoControlCode, // control code of operation to perform
        LPVOID lpInBuffer, // pointer to buffer to supply input data
        DWORD nInBufferSize, // size of input buffer
        LPVOID lpOutBuffer, // pointer to buffer to receive output data
        DWORD nOutBufferSize, // size of output buffer
        LPDWORD lpBytesReturned, // pointer to variable to receive output byte count
        LPOVERLAPPED lpOverlapped  // pointer to overlapped structure for asynchronous operation
       );
      

  6.   

    下面是一个例子,你先试试。刚找的还没试验。http://www.codeproject.com/printing/print_location.asp// wrapper class for the printer API...class GPrinter 
    {
    public:
       GPrinter();   // open a printer with the name 'lpszPrinterName'
       BOOL Open(LPCTSTR lpszPrinterName, PRINTER_DEFAULTS *lpDefaults=NULL);
       // get various types of printer info    
       // pInfo is good for the lifetime of the class, or until the next call to Get(),
       // whichever comes first
       BOOL Get(PRINTER_INFO_1 *pInfo);
       BOOL Get(PRINTER_INFO_2 *pInfo);
       BOOL Get(PRINTER_INFO_3 *pInfo);
       BOOL Get(PRINTER_INFO_4 *pInfo);
       BOOL Get(PRINTER_INFO_5 *pInfo);
       BOOL Get(PRINTER_INFO_7 *pInfo);
       // set to TRUE to turn off message box reporting of errors
       void SetSilent(BOOL bSilent=TRUE);
       // handy operator to return printer object handle
       operator HANDLE() const {return m_hPrinter;}protected:
       BOOL Get(int nLevel, LPBYTE lpBuf, int nBufSize);   HANDLE m_hPrinter;      // handle to the printer object
       LPBYTE m_lpGetInfoBuf;  // temporary buffer
       BOOL m_bSilent;         // silent mode flagpublic:
       // closes the open printer object
       void Close();   virtual ~GPrinter();
    };