请教各位大侠: 如何在win98环境下编程找出系统硬件
解决方案 »
- 郁闷...搞界面有前途吗?
- C Runtime 库的几个概念?
- MFC下如何打开文件
- MFC 多文档 关闭程序时‘蹦’的一声,大家帮忙看下。
- 如何改变list控件显示内容的字体呢?
- 我想学mfc编程,请问从哪里下载实例教程,最好从最基本的例子开始的。谢谢
- 为什么我的VC ADO程序不认识_ConnectionPtr m_pConnect;指针,#inport也做了。这是为什么呀?该在VIEW还是在APP里面加呢?
- sdi程序,用多媒体定时器的callback向view发消息,软件退出时出错
- IDR_MAINFRAME 问题?????????????????????????????????
- capCreateCaptureWindow中需要的的那个窗口句柄参数,怎么才能得到一个有关闭按钮的窗口作参数
- 请教各位大虾:用什么方法可以用编程实现添加Internet Port
- 請問怎樣在窗口的任意位置顯示菜單呢,(不是電擊鼠標右鍵而彈出的那種)
#include <stdio.h>
#include <windows.h>
#include <setupapi.h>
#include <devguid.h>
#include <regstr.h>
#pragma comment(lib,"Setupapi.lib")
int main( )
{
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData; DWORD i;
GUID aa;
GUID *ab;
ab=&aa;
i=sizeof(GUID);
DWORD DataT;
char buf[255];
memset(buf,0,256);
LPTSTR buffer = buf;
DWORD buffersize = 0;
if(!SetupDiClassGuidsFromName("System",ab,i,&i))//通过设备类名得到设备类型的GUID
{
printf("false");
return 1;
}
hDevInfo = SetupDiGetClassDevs(ab, 0, 0, 0);//DIGCF_PRESENT | DIGCF_ALLCLASSES );//通过设备类型GUID得到这类设备信息的句柄
if (hDevInfo == INVALID_HANDLE_VALUE)
{
// Insert error handling here.
return 1;
}
// Enumerate through all devices in Set.
printf("GUID={%X-%X-%X-%X%X-%X%X%X%X%X%X}\n",ab->Data1,ab->Data2,ab->Data3,ab->Data4[0],ab->Data4[1],ab->Data4[2],ab->Data4[3],ab->Data4[4],ab->Data4[5],ab->Data4[6],ab->Data4[7]);
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i = 0;SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData); i++)//枚举这类设备中所有的设备
{ for(int s=0;s<2;s++)//因为有些时候第一次调用SetupDiGetDeviceRegistryProperty可能会失败,所以调用两次,
{
SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_DEVICEDESC,
&DataT, (PBYTE)buffer, buffersize, &buffersize);//得到设备属性
}
printf("设备: [ %s size=%d ]\n",buffer,buffersize);
memset(buf,0,256);
for (int m = 0;
SetupDiEnumDeviceInterfaces(hDevInfo,
&DeviceInfoData,
ab,m,&DeviceInterfaceData); m++)//枚举这类设备中所有的设备
{
printf("GUID={%X-%X-%X-%X%X-%X%X%X%X%X%X}\n",DeviceInterfaceData.InterfaceClassGuid.Data1,DeviceInterfaceData.InterfaceClassGuid.Data2,DeviceInterfaceData.InterfaceClassGuid.Data3,DeviceInterfaceData.InterfaceClassGuid.Data4[0],
DeviceInterfaceData.InterfaceClassGuid.Data4[1],DeviceInterfaceData.InterfaceClassGuid.Data4[2],DeviceInterfaceData.InterfaceClassGuid.Data4[3],DeviceInterfaceData.InterfaceClassGuid.Data4[4],DeviceInterfaceData.InterfaceClassGuid.Data4[5],
DeviceInterfaceData.InterfaceClassGuid.Data4[6],ab->Data4[7]);
//printf("设备: [ %s size=%d ]\n",buffer,buffersize);
//memset(buf,0,256);
}
//printf("Do you want close this driver (YES)y or (NO)n\n");
/* char ch[128];
scanf("%s",ch);
if(ch[0]=='y')
{
if(SetupDiRemoveDevice(
hDevInfo, &DeviceInfoData))
{
printf("SetupDiRemoveDevice succeed \n");
}
else
{
printf("SetupDiRemoveDevice false");
}
}*/ } if ( GetLastError()!=NO_ERROR && GetLastError()!=ERROR_NO_MORE_ITEMS )
{
// Insert error handling here.
return 1;
}
// Cleanup
SetupDiDestroyDeviceInfoList(hDevInfo);
return 0;
}
/*System-Defined Device Setup Classes Available to Vendors
Battery Devices
Class = Battery
ClassGuid = {72631e54-78a4-11d0-bcf7-00aa00b7b32a}
This class includes drivers of battery devices and UPSs. CD-ROM Drives
Class = CDROM
ClassGuid = {4d36e965-e325-11ce-bfc1-08002be10318}
This class includes drivers of CD-ROM drives, including SCSI CD-ROM drives. By default, the system's CD-ROM class installer also installs a system-supplied CD audio driver and CD-ROM changer driver as Plug and Play filters. Disk Drives
Class = DiskDrive
ClassGuid = {4d36e967-e325-11ce-bfc1-08002be10318}
This class includes drivers of hard disk drives. See also the HDC and SCSIAdapter classes. Display Adapters
Class = Display
ClassGuid = {4d36e968-e325-11ce-bfc1-08002be10318}
This class includes drivers of video adapters, including display drivers and video miniports. Floppy Disk Controllers
Class = FDC
ClassGuid = {4d36e969-e325-11ce-bfc1-08002be10318}
This class includes drivers of floppy disk drive controllers. Floppy Disk Drives
Class= FloppyDisk
ClassGuid= {4d36e980-e325-11ce-bfc1-08002be10318}
This class includes drivers of floppy drives. Hard Disk Controllers
Class = HDC
ClassGuid = {4d36e96a-e325-11ce-bfc1-08002be10318}
This class includes drivers of hard disk controllers, including ATA/ATAPI controllers but not SCSI and RAID disk controllers. Human Interface Devices (HID)
Class = HIDClass
ClassGuid = {745a17a0-74d3-11d0-b6fe-00a0c90f57da}
This class includes devices that export interfaces of the HID class, including HID keyboard and mouse devices, which the installed HID device drivers enumerate as their respective child devices. (See also the Keyboard or Mouse classes later in this list.) IEEE 1284.4 Devices
Class=Dot4
ClassGuid = {48721b56-6795-11d2-b1a8-0080c72e74a2}
This class includes drivers that control the operation of multifunction IEEE 1284.4 peripheral devices. IEEE 1284.4 Print Functions
Class = Dot4Print
ClassGuid = {49ce6ac8-6f86-11d2-ble5-0080c72e74a2}
This class includes Dot4 print functions. A Dot4 print function is a function on a Dot4 device and has a single child device, which is a member of the Printer device setup class. IEEE 1394 Host Bus Controller
Class = 1394
ClassGuid = {6bdd1fc1-810f-11d0-bec7-08002be2092f}
This class includes system-supplied drivers of 1394 host controllers connected on a PCI bus, but not drivers of 1394 peripherals. Imaging Device
Class = Image
ClassGuid = {6bdd1fc6-810f-11d0-bec7-08002be2092f}
This class includes drivers of still-image capture devices, digital cameras, and scanners. IrDA Devices
Class = Infrared
ClassGuid = {6bdd1fc5-810f-11d0-bec7-08002be2092f}
This class includes Serial-IR and Fast-IR NDIS miniports, but see also the Network Adapter class for other NDIS NIC miniports. Keyboard
Class = Keyboard
ClassGuid = {4d36e96b-e325-11ce-bfc1-08002be10318}
This class includes all keyboards. That is, it also must be specified in the (secondary) INF for an enumerated child HID keyboard device. Media Changers
Class = MediumChanger
ClassGuid = {ce5939ae-ebde-11d0-b181-0000f8753ec4}
This class includes drivers of SCSI media changer devices. Memory Technology Driver
Class = MTD
ClassGUID = {4d36e970-e325-11ce-bfc1-08002be10318}
This class includes drivers for memory devices, such as flash memory cards. Modem
Class = Modem
ClassGuid = {4d36e96d-e325-11ce-bfc1-08002be10318}
This class includes modems. An INF for a device of this class installs no device driver(s), but rather specifies the features and configuration information of a particular modem and stores this information in the registry. See also the Multifunction class. Monitor
Class = Monitor
ClassGuid = {4d36e96e-e325-11ce-bfc1-08002be10318}
This class includes display monitors. An INF for a device of this class installs no device driver(s), but rather specifies the features of a particular monitor to be stored in the registry for use by drivers of video adapters. (Monitors are enumerated as the child devices of display adapters.) Mouse
Class = Mouse
ClassGuid = {4d36e96f-e325-11ce-bfc1-08002be10318}
This class includes all mouse devices and other kinds of pointing devices, such as trackballs. That is, this class also must be specified in the (secondary) INF for an enumerated child HID mouse device. Multifunction Devices
Class = Multifunction
ClassGuid = {4d36e971-e325-11ce-bfc1-08002be10318}
This class includes combo cards, such as a PCMCIA modem and netcard adapter. The driver for such a Plug and Play multifunction device is installed under this class and enumerates the modem and netcard separately as its child devices. Multimedia
Class = Media
ClassGuid = {4d36e96c-e325-11ce-bfc1-08002be10318}
This class includes Audio and DVD multimedia devices, joystick ports, and full-motion video capture devices.
Class = MultiportSerial
ClassGuid = {50906cb8-ba12-11d1-bf5d-0000f805f530}
This class includes intelligent multiport serial cards, but not peripheral devices that connect to its ports. It does not include unintelligent (16550-type) mutiport serial controllers or single-port serial controllers (see the Ports class). Network Adapter
Class = Net
ClassGuid = {4d36e972-e325-11ce-bfc1-08002be10318}
This class includes NDIS NIC miniports excluding Fast-IR miniports, NDIS intermediate drivers (of virtual adapters), and CoNDIS MCM miniports. Network Client
Class = NetClient
ClassGuid = {4d36e973-e325-11ce-bfc1-08002be10318}
This class includes network and/or print providers. Network Service
Class = NetService
ClassGuid = {4d36e974-e325-11ce-bfc1-08002be10318}
This class includes network services, such as redirectors and servers. Network Transport
Class = NetTrans
ClassGuid = {4d36e975-e325-11ce-bfc1-08002be10318}
This class includes NDIS protocols, CoNDIS stand-alone call managers, and CoNDIS clients, as well as higher level drivers in transport stacks. PCMCIA Adapters
Class = PCMCIA
ClassGuid = {4d36e977-e325-11ce-bfc1-08002be10318}
This class includes system-supplied drivers of PCMCIA and CardBus host controllers, but not drivers of PCMCIA or CardBus peripherals. Ports (COM & LPT ports)
Class = Ports
ClassGuid = {4d36e978-e325-11ce-bfc1-08002be10318}
This class includes drivers of serial and parallel port devices. See also the MultiportSerial class. Printers
Class = Printer
ClassGuid = {4d36e979-e325-11ce-bfc1-08002be10318}
This class includes printer drivers. Printers, Bus-specific class drivers
Class = PNPPrinters
ClassGuid = {4658ee7e-f050-11d1-b6bd-00c04fa372a7}
This class includes bus-specific print class drivers, which provide printer communication for a specific bus. Processors
Class = Processor
ClassGuid = {50127dc3-0f36-415e-a6cc-4cb3be910b65}
This class includes processor types. SCSI and RAID Controllers
Class = SCSIAdapter
ClassGuid = {4d36e97b-e325-11ce-bfc1-08002be10318}
This class includes SCSI HBA miniports and disk-array controller drivers. Smart Card Readers
Class = SmartCardReader
ClassGuid = {50dd5230-ba8a-11d1-bf5d-0000f805f530}
This class includes drivers for smart card readers. Storage Volumes
Class = Volume
ClassGuid = {71a27cdd-812a-11d0-bec7-08002be2092f}
This class includes storage volumes as defined by the system-supplied logical volume manager and class drivers that create device objects to represent storage volumes, such as the system disk class driver. System Devices
Class = System
ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318}
This class includes HALs, system bus drivers, the system ACPI driver, and the system volume manager driver. It also includes battery drivers and UPS drivers. Tape Drives
Class = TapeDrive
ClassGuid = {6d807884-7d21-11cf-801c-08002be10318}
This class includes drivers of tape drives, including all tape miniclass drivers. USB
Class = USB
ClassGuid = {36fc9e60-c465-11cf-8056-444553540000}
This class includes system-supplied (bus) drivers of USB host controllers and drivers of USB hubs, but not drivers of USB peripherals. System-Defined Device Setup Classes Reserved for System Use
The following classes and GUIDs should not be used to install devices (or drivers) on Windows 2000 or later platforms: Adapter
Class = Adapter
ClassGUID = {4d36e964-e325-11ce-bfc1-08002be10318}
This class is obsolete. APM
Class = APMSupport
ClassGUID = {d45b1c18-c8fa-11d1-9f77-0000f805f530}
This class is reserved for system use. Bluetooth
Class = Bluetooth
ClassGUID = {e0cbf06c-cd8b-4647-bb8a-253b43f0f974}
This class is reserved for system use. Computer
Class = Computer
ClassGUID = {4d36e966-e325-11ce-bfc1-08002be10318}
This class is reserved for system use. Decoders
Class = Decoder
ClassGUID = {6bdd1fc2-810f-11d0-bec7-08002be2092f}
This class is reserved for future use. Global Positioning System
Class = GPS
ClassGUID = {6bdd1fc3-810f-11d0-bec7-08002be2092f}
This class is reserved for future use. No driver
Class = NoDriver
ClassGUID = {4d36e976-e325-11ce-bfc1-08002be10318}
This class is obsolete. Non-Plug and Play Drivers
Class = LegacyDriver
ClassGUID = {8ecc055d-047f-11d1-a537-0000f8753ed1}
This class is reserved for system use. Other Devices
Class = Unknown
ClassGUID = {4d36e97e-e325-11ce-bfc1-08002be10318}
This class is reserved for system use. Enumerated devices for which the system cannot determine the type are installed under this class. Do not use this class if you're unsure in which class your device belongs. Either determine the correct device setup class or create a new class. Printer Upgrade
Class = Printer Upgrade
ClassGUID = {4d36e97a-e325-11ce-bfc1-08002be10318}
This class is reserved for system use. Sound
Class = Sound
ClassGUID = {4d36e97c-e325-11ce-bfc1-08002be10318}
This class is obsolete. Built on Wednesday, October 03, 2001
*/