如何获得打印机类别(类型)?

时间:2014-10-31 11:03:47

标签: c++ winapi print-spooler-api

我正在尝试获取打印机类别,例如“传真”或“打印机”,我可以在打印机属性窗口中看到。

我发现的只是我可以从DRIVER_INFO_8,

获取它
DWORD dwNeeded;
LPBYTE lpDriverInfo;
DWORD dwReturned;
DRIVER_INFO_8 *pInfo;
DWORD i;

EnumPrinterDrivers(NULL,
    NULL,
    8,
    NULL,
    0,
    &dwNeeded,
    &dwReturned);

lpDriverInfo = new BYTE[dwNeeded];
if (lpDriverInfo == NULL) {
    return NULL;
}

EnumPrinterDrivers(NULL,
    NULL,
    8,
    lpDriverInfo,
    dwNeeded,
    &dwNeeded,
    &dwReturned);

pInfo = (DRIVER_INFO_8 *)lpDriverInfo;

但是pInfo-> dwDriverAttribute没有显示PRINTER_DRIVER_CATEGORY_FAX,有

    cVersion    3   unsigned long
    pName   0x0000000000496994 L"Microsoft Shared Fax Driver"   wchar_t *
    pEnvironment    0x000000000049697c L"Windows x64"   wchar_t *
    pDriverPath 0x0000000000496916 L"C:\\Windows\\system32\\spool\\DRIVERS\\x64\\3\\FXSDRV.DLL" wchar_t *
    pDataFile   0x00000000004968b2 L"C:\\Windows\\system32\\spool\\DRIVERS\\x64\\3\\FXSUI.DLL"  wchar_t *
    pConfigFile 0x000000000049684e L"C:\\Windows\\system32\\spool\\DRIVERS\\x64\\3\\FXSUI.DLL"  wchar_t *
    pHelpFile   0x0000000000000000 <NULL>   wchar_t *
    pDependentFiles 0x0000000000496574 L"C:\\Windows\\system32\\spool\\DRIVERS\\x64\\3\\FXSWZRD.DLL"    wchar_t *
    pMonitorName    0x0000000000000000 <NULL>   wchar_t *
    pDefaultDataType    0x0000000000000000 <NULL>   wchar_t *
    pszzPreviousNames   0x0000000000000000 <NULL>   wchar_t *
    ftDriverDate    {dwLowDateTime=2743894016 dwHighDateTime=29791429 } _FILETIME
    dwlDriverVersion    1688854653387882    unsigned __int64
    pszMfgName  0x000000000049683a L"Microsoft" wchar_t *
    pszOEMUrl   0x0000000000000000 <NULL>   wchar_t *
    pszHardwareID   0x0000000000496808 L"microsoftmicrosoft_s7d14"  wchar_t *
    pszProvider 0x00000000004967f4 L"Microsoft" wchar_t *
    pszPrintProcessor   0x00000000004967e2 L"winprint"  wchar_t *
    pszVendorSetup  0x0000000000000000 <NULL>   wchar_t *
    pszzColorProfiles   0x0000000000000000 <NULL>   wchar_t *
    pszInfPath  0x0000000000496712 L"C:\\Windows\\System32\\DriverStore\\FileRepository\\prnms002.inf_amd64_neutral_d834e48846616289\\prnms002.inf" wchar_t *
    dwPrinterDriverAttributes   1   unsigned long
    pszzCoreDriverDependencies  0x0000000000000000 <NULL>   wchar_t *
    ftMinInboxDriverVerDate {dwLowDateTime=0 dwHighDateTime=0 } _FILETIME
    dwlMinInboxDriverVerVersion 0   unsigned __int64

所以我有点困惑 - 我怎样才能获得打印机类型?

1 个答案:

答案 0 :(得分:2)

要获取PRINTER_DRIVER_CATEGORY_FAX标记,您至少需要Windows 8或Windows Server 2012(http://msdn.microsoft.com/en-us/library/windows/desktop/dd162507(v=vs.85).aspx)。

尝试使用EnumPrinters代替PRINTER_INFO_2。然后,您可以测试PRINTER_ATTRIBUTE_FAX