public static bool? IsProfileTemp(string sid)
{
try
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(string.Format("{0}\\{1}", ROOT_PROFILE_KEY, sid)))
{
if (key != null)
{
object type = key.GetValue("State");
Profile_State value = 0;
switch (key.GetValueKind("State"))
{
case RegistryValueKind.DWord:
value = (Profile_State)type;
break;
case RegistryValueKind.QWord:
value = (Profile_State)type;
break;
}
if (value.HasFlag(Profile_State.Temporary_profile_loaded))
{
return true;
}
}
else
{
LibraryLogging.Info("IsProfileTemp key {0}\\{1} not found", ROOT_PROFILE_KEY, sid);
return null;
}
}
}
catch (Exception ex)
{
LibraryLogging.Info("IsProfileTemp exception:{0}", ex.Message);
return null;
}
return false;
}