在vcpp中枚举多功能打印机 [英] enumerate Multifunction printer in vcpp
问题描述
大家好我试图找到一个类似windows os的解决方案,当我安装一个多功能打印机(有扫描仪和传真和打印机和.....)我想访问这些设备在vc ++我做了一个snipet允许我获取
可用打印机列表的代码,但我希望能够充分利用打印机内部设备的内容。
示例>> ;打印机:hp xxy
有扫描仪:zyw
有传真:abc
---------------
打印机:三星
有一部电话
有传真:abc
---------------
code可用打印机的收集< / endl;>
$
// SetupDiGetClassDevs
// GUID_DEVINTERFACE_IMAGE在==>中定义Wiaintfc.h
//我认为它延伸到处理程序
HDEVINFO deviceHandler;
//数据
SP_DEVINFO_DATA deviceInfoData;
unsigned long deviceCount = 0;
DEVPROPTYPE ulPropertyType;
// DWORD size = 0,propDataType = 0;
BYTE * propertyBuffer = 0;
/ *
DWORD属性;
PDWORD PropertyRegDataType = NULL; //
PBYTE PropertyBuffer = NULL; * /
DWORD dataT;
TCHAR缓冲区[1024];
DWORD requiredSize;
$
deviceHandler = SetupDiGetClassDevs(NULL,TEXT(" USB"),NULL,DIGCF_PRESENT | DIGCF_ALLCLASSES);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; if(deviceHandler == INVALID_HANDLE_VALUE)
{
COUT<<"处理程序错误"<< endl;
}
//定义尺寸
deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
//在设备上循环
while(SetupDiEnumDeviceInfo(deviceHandler,deviceCount,& deviceInfoData))
{
++ deviceCount;
COUT<<的deviceCount<< ENDL;
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;如果(NBSP;&NBSP;&NBSP; SetupDiGetDeviceRegistryProperty
&NBSP;&NBSP;&NBSP;&NBSP;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------------------------
$
我有结果
7 zh
50 $ $ b $ 00 0035F520
$
设备描述:" Concentrateur USB racine" b
8
required54
0035F520
$
设备描述:"PÚriphÚriqueUSBcomposite"
9 zh
需要38
0035F520
$
设备描述:"HP Officejet J4660"
10
$
required66
0035F520
$
设备描述:"Prize en charge d?impression USB"
11 < br $>
required52
0035F520
$
设备描述:"Officejet J4660(DOT4USB)"¥b $ b 12
required54
0035F520
.............但实际上信息很少;而我试图做的事情就是这样的事情。
就像
####### ################################
$
设备hp打印机xyz
----------------有扫描仪并列出其属性
----------------有 传真 并列出其属性
############################# ##########
$
以及我需要能够命令此扫描仪的方式或者给定打印机中的任何内容
请有任何办法吗?
我可以使用什么功能或lib
谢谢
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</endl;>
//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;
TCHAR buffer[1024];
DWORD requiredSize;
deviceHandler= SetupDiGetClassDevs(NULL, TEXT("USB"),NULL, DIGCF_PRESENT|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;
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;
}
}
SetupDiDestroyDeviceInfoList(deviceHandler);
-----------------------------------------------------------
and i have got this result
7
required50
0035F520
Device Description: "Concentrateur USB racine"
8
required54
0035F520
Device Description: "PÚriphÚrique USB composite"
9
required38
0035F520
Device Description: "HP Officejet J4660"
10
required66
0035F520
Device Description: "Prise en charge d?impression USB"
11
required52
0035F520
Device Description: "Officejet J4660 (DOT4USB)"
12
required54
0035F520
.............but in fact there is few info and what i 'm try to do is something
like
#######################################
device hp printer xyz
----------------has a scanner and to list its properties
----------------has a fax and to list its properties
#######################################
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
推荐答案
枚举,
很抱歉,这也不是正确的论坛。该论坛专门用于定制和编程MS Project,一个计划和调度应用程序。 Sapna本应该引导你到这个论坛:
Sorry but this isn't the right forum either. This forum is exclusively for customizing and and programming MS Project, a planning and scheduling application. Sapna should have directed you to this forum:
http://social.technet.microsoft.com/Forums/en/whatforum/threads 跨度>
祝你好运为您的问题寻求帮助。如果您觉得这可以回答您的问题,请将其标记为已接听。
John
这篇关于在vcpp中枚举多功能打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!