這時候就可以使用Devcon來幫助我們了解裝置與驅動程式間是否正常運作,但我們也可以自己寫一個類似的小工具來使用。
使用只會顯示ERROR Code,不會顯示ERROR Message,但自己寫的工具就可以加入更多的資訊,在適當的時候協助釐清問題的根本。
以下貼出使用的程式碼與ERROR Code對應的ERROR Message
BOOL ListALLDevice() { HDEVINFO hDevInfo; DWORD i, j; BOOL bFound = FALSE; DWORD Status, Problem; CONFIGRET cr = CR_SUCCESS; CHAR * cStatus[] = {"Hardware ID", "Hardware Name"}; UCHAR ucSPDRP[5]; ucSPDRP[0] = SPDRP_HARDWAREID; ucSPDRP[1] = SPDRP_DEVICEDESC; hDevInfo = SetupDiGetClassDevs(NULL, 0, 0, DIGCF_PRESENT | DIGCF_ALLCLASSES ); if (hDevInfo == INVALID_HANDLE_VALUE ) { printf("Unable to enumerate device\n"); return FALSE; } SP_DEVINFO_DATA DeviceInfoData; DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); for ( i = 0 ; SetupDiEnumDeviceInfo( hDevInfo, i, &DeviceInfoData ) ; i++ ) { for(j = 0 ; j < 2 ; j++) { DWORD DataType; LPSTR Buffer = NULL; DWORD BufferSize = 0; while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, ucSPDRP[j], &DataType, ( PBYTE ) Buffer, BufferSize, &BufferSize ) ) { if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER ) { // Change the buffer size. if ( Buffer ) LocalFree( Buffer ); Buffer = (LPSTR) LocalAlloc( LPTR, BufferSize * 2 ); } else break;// Insert error handling here. } printf( "%s : %s\n", cStatus[j], (const char *)Buffer); if ( Buffer ) LocalFree( Buffer ); } cr = CM_Get_DevNode_Status(&Status, &Problem, DeviceInfoData.DevInst, 0); printf("Device status :\n"); if(Status & DN_HAS_PROBLEM) { printf("\tERROR Message : %s\n", DeviceErrorMessage[Problem]); printf("\tERROR code : %d\n", Problem); } else printf("\tDevice is running.\n"); printf("\n"); } SetupDiDestroyDeviceInfoList(hDevInfo); return TRUE; }
ERROR Code與ERROR Message對應表
ERROR
Code
|
ERROR Message
|
1
|
This device is not configured correctly
|
2
|
Windows could not load the driver for
this device because the computer is reporting two
|
3
|
The driver for this device may be bad, or
your system may be running low on memory or other resources
|
4
|
This device is not working properly
because one of its drivers may be bad, or your registry may be bad
|
5
|
The driver for this device requested a
resource that Windows does not know how to handle
|
6
|
Another device is using the resources
this device needs
|
7
|
The drivers for this device need to be
reinstalled
|
8
|
This device is not working properly
because Windows cannot load the file
|
9
|
This device is not working properly
because the BIOS in your computer is reporting the resources for the device
incorrectly
|
10
|
This device is either not present, not
working properly, or does not have all the drivers installed
|
11
|
Windows stopped responding while
attempting to start this device, and therefore will never attempt to start
this device again
|
12
|
This device cannot find any free
resources to use
|
13
|
This device is either not present, not
working properly, or does not have all the drivers installed
|
14
|
This device cannot work properly until
you restart your computer
|
15
|
This device is causing a resource
conflict
|
16
|
Windows could not identify all the
resources this device uses
|
17
|
The driver information file
|
18
|
The drivers for this device need to be
reinstalled
|
19
|
Your registry may be bad Windows
could not load one of the drivers for this device
|
20
|
Windows could not load one of the drivers
for this device
|
21
|
Windows is removing this device
|
22
|
This device is disabled This device is
not started
|
23
|
This display adapter is functioning
correctly This device is not started
|
24
|
This device is either not present, not
working properly, or does not have all the drivers installed
|
25
|
Windows is in the process of setting up
this device
|
26
|
Windows is in the process of setting up
this device
|
27
|
Windows cant specify the resources for
this device
|
28
|
The drivers for this device are not
installed
|
29
|
This device is disabled because the BIOS
for the device did not give it any resources
|
30
|
This device is using an Interrupt Request
IRQ resource that is in use by another device and cannot be shared
|
31
|
This device is not working properly
because
|
32
|
Windows cannot install the drivers for
this device because it cannot access the drive or network location that has
the setup files on it
|
33
|
This device isn’t responding to its
driver
|
34
|
Windows cannot determine the settings for
this device
|
35
|
Your computer’s system firmware does not
include enough information to properly configure and use this device
|
36
|
This device is requesting a PCI interrupt
but is configured for an ISA interrupt
|
37
|
Windows cannot initialize the device
driver for this hardware
|
38
|
Windows cannot load the device driver for
this hardware because a previous instance of the device driver is still in
memory
|
39
|
Windows cannot load the device driver for
this hardware The driver may be corrupted or missing
|
40
|
Windows cannot access this hardware
because its service key information in the registry is missing or recorded
incorrectly
|
41
|
Windows successfully loaded the device
driver for this hardware but cannot find the hardware device
|
42
|
Windows cannot load the device driver for
this hardware because there is a duplicate device already running in the
system
|
43
|
Windows has stopped this device because
it has reported problems
|
44
|
An application or service has shut down
this hardware device
|
45
|
Currently, this hardware device is not
connected to the computer
|
46
|
Windows cannot gain access to this
hardware device because the operating system is in the process of shutting
down
|
47
|
Windows cannot use this hardware device
because it has been prepared for "safe removal", but it has not
been removed from the computer
|
48
|
The software for this device has been
blocked from starting because it is known to have problems with Windows
|
49
|
Windows cannot start new hardware devices
because the system hive is too large exceeds the Registry Size Limit)
|
50
|
Failed to apply one or more registry
properties
|
51
|
This device is currently waiting on
another device or set of devices to start
|
52
|
Windows cannot verify the digital
signature for the drivers required for this device
|
53
|
沒有留言:
張貼留言