( Index )
Month

Brief Information about the Oct '04 CSIG Meeting

Unknown Devices Utility

B. Arnold

Mailing List

Welcome back to the CSIG, a Special Interest Group of the ACGNJ. The subject for this month is a discussion about the MFC Windows Programming using Microsoft Visual C++ version 6.0.

The program presented is designed to help diagnose and fix Device Manager driver problems. Here's a typical situation: When you go to Control Panel, System, Hardware, Device Manager to troubleshoot a hardware problem, you discover that there are some yellow exclamation point icons on one or more objects. The object may be named "Unknown" or simply "PCI Device". At this point you seem to be stuck without a clue. Even if it has a good name like "SiS PCI IDE Controller" you still may have trouble finding updates.

The program helps solve the problem by looking in the Registry and listing more information about the problem. It shows Keys, Descriptions, Vendor ID's, and Device ID's. There is also a button to jump to a Web base database listing further information.

The program has two major sections, Methods to access information from the Registry and a Custom ListBox Class to provide extra functionality.

The beginning of the evening (starting at 7:30pm) will be a RANDOM ACCESS discussion. The main presentation will present the program.

As always, the ftp site has code and programs from our meetings.

Sample Code

/////////////////////////////////////////////////////////////////////////////
// Process()    Most of the Registry Interogation is performed here.
//              Return strings like:  "SiS Accelerated Graphics Port"

int CUnkDlg::Process(char *pStartPath)
    {
    CString array[MAXCOUNT];
    DWORD index=0, count;           long xx;
    char name[1000], SectionTitle[200] = "HKEY_LOCAL_MACHINE\\";

    HUSKEY  hKey1,      // ie, points to "PCI".
            hKey2;      // ie, points to "VEN_1039&DEV_0001&SUBSYS_00000000&REV_00"

                        //  IN       IN     IN     OUT     IN
    xx=SHRegOpenUSKey(pStartPath, KEY_READ, NULL, &hKey1, TRUE); if (ERROR_SUCCESS != xx) return 0;

    while(1)        // Enumerate VEN keys under ...\PCI
        {
        count = 1000;
                        //  IN     IN   OUT   OUT
        xx=SHRegEnumUSKey(hKey1, index, name, &count, SHREGENUM_HKLM); if (ERROR_SUCCESS != xx) break;

                        //  IN      IN     IN       OUT     IN
        xx=SHRegOpenUSKey(name, KEY_READ, hKey1, &hKey2, TRUE);
        if (ERROR_SUCCESS == xx)
            {
            while(1)        // Enumerate keys under ...\PCI\VEN...
                {
                //array[index].Format("%03d  ", index);
                //array[index] += name;
                //array[index] += "    ";
                //array[index] += GetFirstDeviceDesc(hKey2);

                array[index].Format("%03d  %-40s  %s ", index, name, GetFirstDeviceDesc(hKey2));
                break;  // do it only once.
                }
            SHRegCloseUSKey(hKey2);
            if (++index == MAXCOUNT) break;
            }
        }
    SHRegCloseUSKey(hKey1);


    m_Devices.AddString("");
    strcat(SectionTitle, pStartPath);
    m_Devices.AddString(SectionTitle);
    strset(SectionTitle, '-');          // Underline the section heading
    m_Devices.AddString(SectionTitle);

    for (unsigned int i=0; i < index; i++)
        m_Devices.AddString(array[i]);

    return index;
    }

"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page