000
10.10.2012, 12:04 Uhr
~TaFa
Gast
|
Hallo , bin schon am verzweifeln. Ich möchte Programmgesteuert herausfinden, ob der angeschlossene Drucker den Status ONLINE/OFFLINE hat. Über PRINTER_INFO_5 kann ich PRINTER_ATTRIBUTE auslesen, was so weit funktioniert. Wenn ich aber den Drucker über Windows (WIN7) auf offline setze, kriege ich den PRINTER_ATTRIBUTE-Wert=0x00000640 und auf Online 0x00000240 beide Werte sind aber in Winspool.h nicht definiert :eek: Hat jemand ne Idee, ob die beiden Werte wirklich ON/OFFLINE-Status repräsentieren?
Code: |
Winspool.h Attribute #define PRINTER_ATTRIBUTE_QUEUED 0x00000001 #define PRINTER_ATTRIBUTE_DIRECT 0x00000002 #define PRINTER_ATTRIBUTE_DEFAULT 0x00000004 #define PRINTER_ATTRIBUTE_SHARED 0x00000008 #define PRINTER_ATTRIBUTE_NETWORK 0x00000010 #define PRINTER_ATTRIBUTE_HIDDEN 0x00000020 #define PRINTER_ATTRIBUTE_LOCAL 0x00000040 #define PRINTER_ATTRIBUTE_ENABLE_DEVQ 0x00000080 #define PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS 0x00000100 #define PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST 0x00000200 #define PRINTER_ATTRIBUTE_WORK_OFFLINE 0x00000400 #define PRINTER_ATTRIBUTE_ENABLE_BIDI 0x00000800 #define PRINTER_ATTRIBUTE_RAW_ONLY 0x00001000 #define PRINTER_ATTRIBUTE_PUBLISHED 0x00002000 #define PRINTER_ATTRIBUTE_FAX 0x00004000 #define PRINTER_ATTRIBUTE_TS 0x00008000 #define PRINTER_ATTRIBUTE_PUSHED_USER 0x00020000 #define PRINTER_ATTRIBUTE_PUSHED_MACHINE 0x00040000 #define PRINTER_ATTRIBUTE_MACHINE 0x00080000 #define PRINTER_ATTRIBUTE_FRIENDLY_NAME 0x00100000
|
C++: |
CString str,name; DWORD dwNeeded, dwReturned; PRINTER_INFO_5 *pInfo5;
EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5, NULL, 0, &dwNeeded, &dwReturned); pInfo5 = new PRINTER_INFO_5[dwNeeded]; EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5, (PBYTE) pInfo5, dwNeeded, &dwNeeded, &dwReturned);
if(NULL != pInfo5) { PRINTER_INFO_5 *pDrucker = pInfo5;
for(UINT i = 0; i < dwReturned; i++) { str.Format("NAME:%s PORT:%s Attrib:%d",pDrucker->pPrinterName ,pDrucker->pPortName, pDrucker->Attributes); name = pDrucker->pPortName; if( (name.MakeUpper().Find("USB") != -1)) { m_List.AddString( str); switch(pDrucker->Attributes) { case PRINTER_ATTRIBUTE_DIRECT : m_List.AddString("PRINTER_ATTRIBUTE_DIRECT "); break; case PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST : m_List.AddString("PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST ");break; case PRINTER_ATTRIBUTE_ENABLE_DEVQ : m_List.AddString("PRINTER_ATTRIBUTE_ENABLE_DEVQ ");break; case PRINTER_ATTRIBUTE_HIDDEN : m_List.AddString("PRINTER_ATTRIBUTE_HIDDEN ");break; case PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS : m_List.AddString("PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS ");break; case PRINTER_ATTRIBUTE_LOCAL : m_List.AddString("PRINTER_ATTRIBUTE_LOCAL ");break; case PRINTER_ATTRIBUTE_NETWORK : m_List.AddString("PRINTER_ATTRIBUTE_NETWORK ");break; case PRINTER_ATTRIBUTE_PUBLISHED : m_List.AddString("PRINTER_ATTRIBUTE_PUBLISHED ");break; case PRINTER_ATTRIBUTE_QUEUED : m_List.AddString("PRINTER_ATTRIBUTE_QUEUED ");break; case PRINTER_ATTRIBUTE_RAW_ONLY : m_List.AddString("PRINTER_ATTRIBUTE_RAW_ONLY ");break; case PRINTER_ATTRIBUTE_SHARED : m_List.AddString("PRINTER_ATTRIBUTE_SHARED ");break; case PRINTER_ATTRIBUTE_FAX : m_List.AddString("PRINTER_ATTRIBUTE_FAX ");break; case PRINTER_ATTRIBUTE_FRIENDLY_NAME : m_List.AddString("PRINTER_ATTRIBUTE_FRIENDLY_NAME"); break; case PRINTER_ATTRIBUTE_MACHINE : m_List.AddString("PRINTER_ATTRIBUTE_MACHINE ");break; case PRINTER_ATTRIBUTE_PUSHED_USER : m_List.AddString("PRINTER_ATTRIBUTE_PUSHED_USER ");break; case PRINTER_ATTRIBUTE_PUSHED_MACHINE : m_List.AddString("PRINTER_ATTRIBUTE_PUSHED_MACHINE");break; case PRINTER_ATTRIBUTE_WORK_OFFLINE : m_List.AddString("PRINTER_ATTRIBUTE_WORK_OFFLINE");break; case PRINTER_ATTRIBUTE_ENABLE_BIDI : m_List.AddString("PRINTER_ATTRIBUTE_ENABLE_BIDI");break; case PRINTER_ATTRIBUTE_TS : m_List.AddString("PRINTER_ATTRIBUTE_TS");break; case PRINTER_ATTRIBUTE_DEFAULT : m_List.AddString("PRINTER_ATTRIBUTE_DEFAULT");break; case PRINTER_ATTRIBUTE_TS_GENERIC_DRIVER : m_List.AddString("PRINTER_ATTRIBUTE_TS_GENERIC_DRIVER");break; default: m_List.AddString("UNDEFINIERT;"); // IMMER UNDEFINIERT!!!! } } pDrucker++; } } delete[] pInfo5;
|
|