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()
{
unsigned long level =6; DRIVER_INFO_6 * listOfDrivers; unsigned long pointedSizeOfDriverInfo;
unsigned long sizeOfDriverInfo;
unsigned long sizeOfStructure;
int result;
EnumPrinterDrivers(
NULL, NULL, level,
NULL , 0, &sizeOfDriverInfo,
&sizeOfStructure
);
cout<<"the size of driver info "<<sizeOfDriverInfo<<endl;
if(sizeOfDriverInfo>0)
{
listOfDrivers=new DRIVER_INFO_6[sizeOfDriverInfo];
result=EnumPrinterDrivers(
NULL, NULL, level,
(LPBYTE)listOfDrivers , sizeOfDriverInfo , &sizeOfDriverInfo,
&sizeOfStructure
);
if(result>0)
{
cout<<"the size of collection "<<sizeOfStructure<<endl;
for(int index=0;index<sizeOfStructure;index++)
{
cout<<" ------------------------------------------------------------- "<<endl;
wcout<<"Driver Name "<<listOfDrivers[index].pName<<endl;
wcout<<"Driver path "<<listOfDrivers[index].pDriverPath<<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;
}
}
delete [] listOfDrivers;
}
}
is there any idea ?
i did this but i don't know what next
HDEVINFO deviceHandler;
SP_DEVINFO_DATA deviceInfoData;
unsigned long deviceCount=0;
DEVPROPTYPE ulPropertyType;
BYTE * propertyBuffer=0;
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;
}
deviceInfoData.cbSize=sizeof(SP_DEVINFO_DATA);
while(SetupDiEnumDeviceInfo(deviceHandler,deviceCount,&deviceInfoData))
{
++deviceCount;
cout<<deviceCount<<endl;
SetupDiGetDeviceRegistryProperty
(
deviceHandler,
&deviceInfoData,
SPDRP_DEVICEDESC, &dataT, (PBYTE)buffer, requiredSize, &requiredSize
);
cout<<"required"<<requiredSize<<endl;
}
SetupDiDestroyDeviceInfoList(deviceHandler);
i have improved little bit the code inside the loop
if( SetupDiGetDeviceRegistryProperty
(
deviceHandler,
&deviceInfoData,
SPDRP_DEVICEDESC, &dataT,
(BYTE*)buffer, sizeof(buffer), &requiredSize
))
{
cout<<"required"<<requiredSize<<endl;
cout<<buffer<<endl;
_tprintf (TEXT(" Device Description: \"%s\"\n"), buffer);
}
else
{
cout<<" false \n"<<endl;
}
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...