PowerUsers 权限下 读注册表不行,写可以 困惑!!!
UINT CRegistry::GetProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nDefault)
{
ASSERT(lpszSection != NULL);
ASSERT(lpszEntry != NULL);
HKEY hSecKey = GetSectionKey(lpszSection);
if (hSecKey == NULL)
return nDefault;
DWORD dwValue;
DWORD dwType;
DWORD dwCount = sizeof(DWORD);
LONG lResult = RegQueryValueEx(hSecKey, (LPTSTR)lpszEntry, NULL, &dwType,
(LPBYTE)&dwValue, &dwCount);
RegCloseKey(hSecKey);
if (lResult == ERROR_SUCCESS)
{
ASSERT(dwType == REG_DWORD);
ASSERT(dwCount == sizeof(dwValue));
return (UINT)dwValue;
}
return nDefault;
}
CRegistry reg;
sTemp = _T("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\") + sDevice + _T("\\Connection\\");
lpszSubKey = (LPCTSTR)sTemp.GetBuffer(20000);
sTemp.ReleaseBuffer();
nValue = reg.GetProfileInt(lpszSubKey, _T("MediaSubType"), 0);
注册表的位置是SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1 -08002BE10318}\{5C55B069-AA1D-4EC6-9921-2B670E4486DA}\Connection\
administrator 权限可以读到,但是powerusers就不行
但是可以有修改权限
BOOL CRegistry::WriteProfileBinary(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPBYTE pData, UINT nBytes)
{
ASSERT(lpszSection != NULL);
LONG lResult;
HKEY hSecKey = GetSectionKey(lpszSection);
if (hSecKey == NULL)
return FALSE;
lResult = RegSetValueEx(hSecKey, lpszEntry, NULL, REG_BINARY,
pData, nBytes);
RegCloseKey(hSecKey);
return lResult == ERROR_SUCCESS;
}
注册表的位置是 SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\{5C55B069-AA1D-4EC6-9921-2B670E4486DA}
reg.WriteProfileBinary(lpszSubKey, _T("1"), (LPBYTE)cInfVal, nDataSize)
这个可以修改,不知道为什么