本文介绍了枚举vc ++中的多功能打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

0下来投票最爱





嗨我们试图找到一个类似windows os的解决方案,当我安装多功能打印机时(有一个扫描仪和传真和打印机和.....)我想访问vc ++上的那些设备我做了一个代码的snipet,允许我获得可用的打印机列表,但我想掩盖打印机有什么样的内部设备



示例>>打印机:hp xxy



有扫描仪:zyw



有传真:abc



---------------



printer:samsung



有一部电话



有传真:abc



---------------



可用打印机收藏代码



0 down vote favorite


hi guys i tried to find a sollution like windows os does when i install a multifunction printer (that has a scanner and fax and printers and .....) i want to access to those device on vc++ i did a snipet of code that allows me to get the list of available printers but i want to enumirate what a printer has like internal devices

example >> printer : hp xxy

has a scanner : zyw

has a fax : abc

---------------

printer : samsung

has a phone

has a fax : abc

---------------

code for colleciton of available printers

void outAllDevicesDrivers()
{
    //>> try to get all drivers of printers
    unsigned long level =6; // equivalent to DWORD
    DRIVER_INFO_6 * listOfDrivers;  // appropiete driver params
    unsigned long pointedSizeOfDriverInfo;
    unsigned long sizeOfDriverInfo;
    unsigned long sizeOfStructure;
    int result;
    EnumPrinterDrivers(
            NULL, //context of search local Drivers
            NULL, // Environment of search
            level,
            NULL ,// collection 
            0,    // the buffer
            &sizeOfDriverInfo,
            &sizeOfStructure
        );
    cout<<"the size of driver info "<<sizeOfDriverInfo<<endl;
    //>> allocating the required space
    if(sizeOfDriverInfo>0)
    {
        //cout<<"the number of collection "<<sizeOfDriverInfo/sizeof(DRIVER_INFO_6)<<endl;
    listOfDrivers=new DRIVER_INFO_6[sizeOfDriverInfo];

    result=EnumPrinterDrivers(
        NULL, //context of search local Drivers
        NULL, // Environment of search
        level,
        (LPBYTE)listOfDrivers ,// collection 
        sizeOfDriverInfo ,     // the buffer
        &sizeOfDriverInfo,
        &sizeOfStructure
    );


    if(result>0)
    {
        cout<<"the size of collection "<<sizeOfStructure<<endl;
        for(int index=0;index<sizeOfStructure;index++)
        // for(int index=sizeOfStructure-1;index>=0;index--) reverse loop 
        {
            cout<<" ------------------------------------------------------------- "<<endl;
                //wcout<<"Driver Name "<<listOfDrivers[index].<<endl;
            wcout<<"Driver Name "<<listOfDrivers[index].pName<<endl;
            wcout<<"Driver path "<<listOfDrivers[index].pDriverPath<<endl;
            //wcout<<"DriverType  "<<listOfDrivers[index].pDependentFiles<<endl;
            wcout<<"platform : "<<listOfDrivers[index].pEnvironment<<endl;
            if(listOfDrivers[index].pszHardwareID)
                wcout<<"HardWare ID : "<<listOfDrivers[index].pszHardwareID<<endl;
            if(listOfDrivers[index].dwlDriverVersion)
                wcout<<"Driver Version : "<<listOfDrivers[index].dwlDriverVersion<<endl;
            if(listOfDrivers[index].pConfigFile)
                wcout<<"Driver configuration : "<<listOfDrivers[index].pConfigFile<<endl;
            if(listOfDrivers[index].pDependentFiles)
                wcout<<"Driver dependecies  : "<<listOfDrivers[index].pDependentFiles<<endl;
            if(listOfDrivers[index].pszMfgName)
                wcout<<"Driver Manufacture  : "<<listOfDrivers[index].pszMfgName<<endl;

            cout<<""<<endl;
        }


    }
    //>>

        //for(int index=0;index




        //>> free the space 
        delete [] listOfDrivers;
}

}





有什么想法吗?



i这样做但我不知道是什么下一页



is there any idea ?

i did this but i don''t know what next

//SetupDiGetClassDevs
// GUID_DEVINTERFACE_IMAGE defined in ==> Wiaintfc.h
// i think it extends from a handler
 HDEVINFO deviceHandler;
 // data
SP_DEVINFO_DATA deviceInfoData;
  unsigned long deviceCount=0;
 DEVPROPTYPE ulPropertyType;
//DWORD size=0,propDataType=0;

BYTE * propertyBuffer=0;

/*
DWORD Property;
PDWORD PropertyRegDataType=NULL; //
PBYTE PropertyBuffer=NULL;*/


DWORD dataT=0;
LPTSTR buffer=NULL;
DWORD requiredSize;


 deviceHandler= SetupDiGetClassDevsW(&GUID_DEVINTERFACE_VOLUME, NULL, NULL,DIGCF_ALLCLASSES);
    if(deviceHandler==INVALID_HANDLE_VALUE)
    {
        cout<<" handler error "<<endl;
    }
    //define size
    deviceInfoData.cbSize=sizeof(SP_DEVINFO_DATA);
    // loop on the devices
    while(SetupDiEnumDeviceInfo(deviceHandler,deviceCount,&deviceInfoData))
    {
        ++deviceCount;
        cout<<deviceCount<<endl;


                                SetupDiGetDeviceRegistryProperty
                                (
                                deviceHandler,
                                &deviceInfoData,
                                SPDRP_DEVICEDESC,           // const property
                                &dataT,     // in out NULL
                                (PBYTE)buffer,//PropertyBuffer,     // in out NULL => required size
                                requiredSize,//PropertyBufferSize, // in 0=========>
                                &requiredSize
                                );




        cout<<"required"<<requiredSize<<endl;





    }

    SetupDiDestroyDeviceInfoList(deviceHandler);









i里面的代码改善了一点点循环







i have improved little bit the code inside the loop

if(	SetupDiGetDeviceRegistryProperty
									(
									deviceHandler,
									&deviceInfoData,
									SPDRP_DEVICEDESC,			// const property
									&dataT,		// in out NULL
									/**************/
									(BYTE*)buffer,//PropertyBuffer,     // in out NULL => required size
									sizeof(buffer),//PropertyBufferSize, // in 0=========>
									&requiredSize
									))
								{
								cout<<"required"<<requiredSize<<endl;
								cout<<buffer<<endl;
								_tprintf (TEXT("    Device Description: \"%s\"\n"), buffer);
								
								}
								else
								{
								cout<<" false \n"<<endl;
								}



i不知道,但我看不到打印机里面的扫描仪

也许我应该更改


i don''t know but i don''t see the scanner that is inside my printer
maybe i should change

deviceHandler= SetupDiGetClassDevsW(NULL, TEXT("USB"),NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES);

与其他东西



和给我的结果是



with other thing

and the result that gives me is

1<br />
required50<br />
0035F520<br />
    Device Description: "Concentrateur USB racine"<br />
2<br />
required50<br />
0035F520<br />
    Device Description: "Concentrateur USB racine"<br />
3<br />
required50<br />
0035F520<br />
    Device Description: "Concentrateur USB racine"<br />
4<br />
required50<br />
0035F520<br />
    Device Description: "Concentrateur USB racine"<br />
5<br />
required50<br />
0035F520<br />
    Device Description: "Concentrateur USB racine"<br />
6<br />
required50<br />
0035F520<br />
    Device Description: "Concentrateur USB racine"<br />
7<br />
required50<br />
0035F520<br />
    Device Description: "Concentrateur USB racine"<br />
8<br />
required54<br />
0035F520<br />
    Device Description: "PÚriphÚrique USB composite"<br />
9<br />
required38<br />
0035F520<br />
    Device Description: "HP Officejet J4660"<br />
10<br />
required66<br />
0035F520<br />
    Device Description: "Prise en charge d?impression USB"<br />
11<br />
required52<br />
0035F520<br />
    Device Description: "Officejet J4660 (DOT4USB)"<br />
12<br />
required54<br />
0035F520<br />
    Device Description: "PÚriphÚrique USB composite"<br />
13<br />
required46<br />
0035F520<br />
    Device Description: "PÚriphÚrique audio USB"<br />
14<br />
required52<br />
0035F520<br />
    Device Description: "PÚriphÚrique d?entrÚe USB"<br />
15<br />
required52<br />
0035F520<br />
    Device Description: "PÚriphÚrique d?entrÚe USB"<br />
16<br />
required52<br />
0035F520<br />
    Device Description: "PÚriphÚrique d?entrÚe USB"<br />
17<br />
required54<br />
0035F520<br />
    Device Description: "PÚriphÚrique USB composite"<br />
18<br />
required46<br />
0035F520<br />
    Device Description: "PÚriphÚrique vidÚo USB"<br />
007E5828<br />
Appuyez sur une touche pour continuer...

推荐答案



这篇关于枚举vc ++中的多功能打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 17:45