Abstractions.Windows.User.FixProfileList C# (CSharp) 메소드

FixProfileList() 공개 정적인 메소드

if a user receives a temp profile of whatever reason MS is renaming the SID key under ProfileList to SID.bak if so winapi calls will fail and not returning anything
public static FixProfileList ( string userSID ) : System.Boolean
userSID string
리턴 System.Boolean
        public static Boolean FixProfileList(string userSID)
        {
            string regkey = ROOT_PROFILE_KEY + "\\" + userSID;
            UIntPtr key = UIntPtr.Zero;
            UIntPtr key_bak = UIntPtr.Zero;
            Boolean ret = false;

            key = Abstractions.WindowsApi.pInvokes.RegistryOpenKey(Abstractions.WindowsApi.pInvokes.structenums.baseKey.HKEY_LOCAL_MACHINE, regkey);
            if (key == UIntPtr.Zero)
            {
                key_bak = Abstractions.WindowsApi.pInvokes.RegistryOpenKey(Abstractions.WindowsApi.pInvokes.structenums.baseKey.HKEY_LOCAL_MACHINE, regkey + ".bak");
                if (key_bak != UIntPtr.Zero)
                {
                    key = Abstractions.WindowsApi.pInvokes.RegistryCreateKey(Abstractions.WindowsApi.pInvokes.structenums.baseKey.HKEY_LOCAL_MACHINE, regkey);
                    if (key != UIntPtr.Zero)
                    {
                        ret = Abstractions.WindowsApi.pInvokes.RegistryCopyKey(key_bak, null, key);
                        if (ret)
                        {
                            if (Abstractions.WindowsApi.pInvokes.RegistryCloseKey(key_bak))
                            {
                                Abstractions.WindowsApi.pInvokes.RegistryDeleteTree(Abstractions.WindowsApi.pInvokes.structenums.baseKey.HKEY_LOCAL_MACHINE, regkey + ".bak");
                            }
                        }
                    }
                }
                else
                {
                    ret = true;
                }
            }
            else
            {
                ret = true;
            }
            if (key_bak != UIntPtr.Zero)
            {
                Abstractions.WindowsApi.pInvokes.RegistryCloseKey(key_bak);
            }
            if (key != UIntPtr.Zero)
            {
                Abstractions.WindowsApi.pInvokes.RegistryCloseKey(key);
            }

            return ret;
        }