void CRS2USBDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
HKEY hKey = HKEY_LOCAL_MACHINE;
DWORD numSubKey = 0;
DWORD i;
DWORD sizeSubKey;
TCHAR subKey[255];
TCHAR szValue[MAX_REG_LENGTH];
unsigned char keyValue[255];
DWORD dwType = REG_SZ;
DWORD cbData = MAX_REG_LENGTH;
int iVNSCounter = 0;
memset(keyValue, 0, 255);
switch(nIDEvent)
{
case TIMER_USB_STATUS:
// Operation registry to get info
RegOpenKeyEx(g_HKEY,
L "Drivers\\Active ",
0,
KEY_READ,
&hKey);
RegQueryInfoKey(hKey,
NULL,
NULL,
NULL,
&numSubKey,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
if(numSubKey)
{
for(i=0; i <numSubKey; i++)
{
subKey[0] = '\0 ';
sizeSubKey = 255;
RegEnumKeyEx(hKey,
i,
subKey,
&sizeSubKey,
NULL,
NULL,
NULL,
NULL);
memset(szValue, 0, sizeof(szValue));
wcscpy(szValue, L "Drivers\\Active\\ ");
wcscat(szValue, subKey);
if(RegOpenKeyEx(g_HKEY, szValue, 0, KEY_READ, &hKey)==ERROR_SUCCESS)
{
if(RegQueryValueEx(hKey, TEXT( "Key "), NULL, &dwType, keyValue, &cbData)==ERROR_SUCCESS)
{
SetDlgItemText(IDC_STATIC_TEMP, (LPCTSTR)keyValue);
CString sTmp;
GetDlgItemText(IDC_STATIC_TEMP, sTmp);
CString s1( "Drivers\\USB\\ClientDrivers\\Venus_USB ");
if(sTmp.Compare(s1)==0)
{
iVNSCounter++;
}
}
}
}
}
break;
default:
break;
}
------解决方案--------------------
貌似你没调用RegCloseKey关闭注册表句柄,当然内存泄漏了!
------解决方案--------------------
代码发给我 我帮你改,[email protected]!