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);
转载于:https://www.cnblogs.com/fanzi2009/archive/2009/07/25/1530668.html