void Remote_Management()
{
//终端服务器使用了SSL加密
string result;
HKEY hEky = NULL;
LPCTSTR read = _T("SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp");
//打开注册表
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, read, 0, KEY_READ, &hEky))
{
string buff;
DWORD dwSize = 0;
DWORD dwSzType = REG_SZ;
string *lpchar = NULL;
//查看共享是否开启
if (ERROR_SUCCESS == RegQueryValueEx(hEky, _T("WdName"), NULL, &dwSzType, NULL, &dwSize))
{
lpchar = new string[dwSize];
if (ERROR_SUCCESS == RegQueryValueEx(hEky, _T("WdName"), NULL, &dwSzType, (LPBYTE)&lpchar, &dwSize))
{
cout << endl;
}
else
cout << endl << "错误1" << endl;
}
else
cout << endl << "错误2" << endl;
}
RegCloseKey(hEky);
return;
}
将代码加上这个:lpchar = new string[dwSize];就报错越界
//终端服务器使用了SSL加密
string result;
HKEY hEky = NULL;
LPCTSTR read = _T("SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp");
//打开注册表
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, read, 0, KEY_READ, &hEky))
{
string buff;
DWORD dwSize = 0;
DWORD dwSzType = REG_SZ;
string *lpchar = NULL;
//查看共享是否开启
if (ERROR_SUCCESS == RegQueryValueEx(hEky, _T("WdName"), NULL, &dwSzType, (LPBYTE)&buff, &dwSize))
{
cout << endl;
}
else
cout << endl << "错误2" << endl;
}
RegCloseKey(hEky);
return;
}
不加的话就变成缓冲区不足
有什么好的解决办法