ATL操作注册表
CRegKey key;
CString strKey = _T("SYSTEM\\CurrentControlSet\\Control\\StorageDevicePolicies");
if(key.Open(HKEY_LOCAL_MACHINE, strKey, KEY_READ) != ERROR_SUCCESS)
{
if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,_T("SYSTEM\\CurrentControlSet\\Control\\StorageDevicePolicies")))
{
MessageBox(_T("You should login with administrator!"));
return 0;
}
}
key.SetDWORDValue(_T("WriteProtect"),1);