工作中

#include <windows.h>
#include <iostream>
#include <string.h>
using namespace std;
 
int main()
{
    const char* path = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\";
    HKEY hKey = 0;
    char buf[255] = {0};
    DWORD dwType = 0;
    DWORD dwBufSize = sizeof(buf);
    char* subkey;
    int	i;

	
    for( i = 1; i < 50; i++ )
    {
        wsprintf(subkey, "%s%d", path, i);
        
        if( RegOpenKey(HKEY_LOCAL_MACHINE, subkey, &hKey) == ERROR_SUCCESS )
        {
            cout << "open " << i << endl;
            
            dwType = REG_SZ;
            if( RegQueryValueEx(hKey,"Description",0, &dwType, (BYTE*)buf, &dwBufSize) == ERROR_SUCCESS )
            {
                cout << buf << endl;
				if( strstr(buf, "Realtek PCIe FE Family Controller") != NULL ) 
                {
                    RegCloseKey(hKey);
					break;
                }
            }
            RegCloseKey(hKey);
		}
    }
	ZeroMemory(buf, sizeof buf);
	wsprintf(subkey, "%s%d", path, i);
        
	if( RegOpenKey(HKEY_LOCAL_MACHINE, subkey, &hKey) == ERROR_SUCCESS )
	{
		cout << "ok" << endl;
		dwType = REG_SZ;
		
		if( RegQueryValueEx(hKey, "ServiceName", 0, &dwType, (BYTE*)buf, &dwBufSize) == ERROR_SUCCESS )
			cout << buf << endl;
	}
	RegCloseKey(hKey);
    
	system("PAUSE");
    return 0;
}

尚未完成