示例#1
0
        /// <summary>
        /// Ends restore
        /// </summary>
        /// <param name="Cancel"></param>
        /// <returns></returns>
        public bool EndRestore(bool Cancel)
        {
            RESTOREPTINFO tRPI = new RESTOREPTINFO();
            SMGRSTATUS tStatus = new SMGRSTATUS();
            bool success = false;

            tRPI.dwEventType = END_SYSTEM_CHANGE;
            tRPI.llSequenceNumber = _lSeqNum;

            if (Cancel == true)
            {
                tRPI.dwRestorePtType = CANCELLED_OPERATION;
            }

            try
            {
                success = (SRSetRestorePointW(ref tRPI, out tStatus));
            }
            finally
            {
                // reset
                cLightning cl = new cLightning();
                cl.WriteDword(cLightning.ROOT_KEY.HKEY_LOCAL_MACHINE, RESTORE_KEY, RESTORE_VALUE, _iRestInt);
            }
            return success;
        }
示例#2
0
        /// <summary>
        /// Starts restore
        /// </summary>
        /// <param name="Description"></param>
        /// <returns></returns>
        public bool StartRestore(string Description)
        {
            int maj = Environment.OSVersion.Version.Major;
            int min = Environment.OSVersion.Version.Minor;
            RESTOREPTINFO tRPI = new RESTOREPTINFO();
            SMGRSTATUS tStatus = new SMGRSTATUS();

            // compatability
            if (!(maj == 4 && min == 90 || maj > 4))
            {
                return false;
            }

            tRPI.dwEventType = BEGIN_SYSTEM_CHANGE;
            tRPI.dwRestorePtType = (int)RESTORE_TYPE.MODIFY_SETTINGS;
            tRPI.llSequenceNumber = 0;
            tRPI.szDescription = Description;

            // test for key that defines multiple restores per cycle
            cLightning cl = new cLightning();
            if (cl.ValueExists(cLightning.ROOT_KEY.HKEY_LOCAL_MACHINE, RESTORE_KEY, RESTORE_VALUE))
            {
                _iRestInt = cl.ReadDword(cLightning.ROOT_KEY.HKEY_LOCAL_MACHINE, RESTORE_KEY, RESTORE_VALUE);
            }
            // set to 2 minutes
            cl.WriteDword(cLightning.ROOT_KEY.HKEY_LOCAL_MACHINE, RESTORE_KEY, RESTORE_VALUE, 2);
            if (SRSetRestorePointW(ref tRPI, out tStatus))
            {
                _lSeqNum = tStatus.llSequenceNumber;
                return true;
            }
            return false;
        }
示例#3
0
 static extern bool SRSetRestorePointW(ref RESTOREPTINFO pRestorePtSpec, out SMGRSTATUS pSMgrStatus);