enumerate Multifunction printer in vc++

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<br/>
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<br/>
<br/>
example >> printer : hp xxy<br/>
<br/>
has a scanner : zyw<br/>
<br/>
has a fax : abc <br/>
<br/>
---------------<br/>
<br/>
printer : samsung<br/>
<br/>
has a phone<br/>
<br/>
has a fax : abc <br/>
<br/>
---------------<br/>
<br/>
code for colleciton of available printers</endl;>

//SetupDiGetClassDevs<br/>
// GUID_DEVINTERFACE_IMAGE defined in ==> Wiaintfc.h<br/>
// i think it extends from a handler <br/>
HDEVINFO deviceHandler;<br/>
// data <br/>
SP_DEVINFO_DATA deviceInfoData;<br/>
unsigned long deviceCount=0; <br/>
DEVPROPTYPE ulPropertyType;<br/>
//DWORD size=0,propDataType=0;<br/>
<br/>
BYTE * propertyBuffer=0;<br/>
<br/>
/*<br/>
DWORD Property;<br/>
PDWORD PropertyRegDataType=NULL; //<br/>
PBYTE PropertyBuffer=NULL;*/<br/>
<br/>
<br/>
DWORD dataT;<br/>
TCHAR buffer[1024];<br/>
DWORD requiredSize;<br/>
<br/>
<br/>
deviceHandler= SetupDiGetClassDevs(NULL, TEXT("USB"),NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES);<br/>
if(deviceHandler==INVALID_HANDLE_VALUE)<br/>
{<br/>
cout<<" handler error "<<endl;<br/>
}<br/>
//define size <br/>
deviceInfoData.cbSize=sizeof(SP_DEVINFO_DATA);<br/>
// loop on the devices<br/>
while(SetupDiEnumDeviceInfo(deviceHandler,deviceCount,&deviceInfoData))<br/>
{<br/>
++deviceCount;<br/>
cout<<deviceCount<<endl;<br/>
if( SetupDiGetDeviceRegistryProperty<br/>
(<br/>
deviceHandler,<br/>
&deviceInfoData,<br/>
SPDRP_DEVICEDESC, // const property<br/>
&dataT, // in out NULL<br/>
/**************/<br/>
(BYTE*)buffer,//PropertyBuffer, // in out NULL => required
size<br/>
sizeof(buffer),//PropertyBufferSize, // in 0=========><br/>
&requiredSize<br/>
))<br/>
{<br/>
cout<<"required"<<requiredSize<<endl;<br/>
cout<<buffer<<endl;<br/>
_tprintf (TEXT(" Device Description: "%s"n"), buffer);<br/>
<br/>
}<br/>
else<br/>
{<br/>
cout<<" false n"<<endl;<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
}<br/>
<br/>
SetupDiDestroyDeviceInfoList(deviceHandler);
-----------------------------------------------------------
and i have got this result

Code:
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
.............but in fact there is few info and what i m try to do is something

like
#######################################
device hp printer xyz <br/>

----------------has a scanner and to list its properties
----------------has a fax and to list its properties
#######################################
Code:
 and by the way i need to be able to command this scanner or what ever that is in a given printer

please is there any way to do it
and what can i use like functions or lib
thank
Code:
<br/>

View the full article
 
Back
Top