Пример #1
0
 static BOOL _DelSysEnv(LPCTSTR lpVarName)
 {
     BOOL bReturn = FALSE;
     ZLRegister reg;
     if (reg.Open(
         HKEY_LOCAL_MACHINE,
         L"System\\CurrentControlSet\\Control\\Session Manager\\Environment",
         FALSE,
         KEY_WRITE))
     {
         bReturn = reg.DeleteValue(lpVarName);
         reg.Close();
     }
     return bReturn;
 }
Пример #2
0
        static BOOL _AddSysEnv(LPCTSTR lpVarName, LPCTSTR lpVar)
        {
            BOOL bReturn = FALSE;

            ZLRegister reg;
            if (reg.Open(
                HKEY_LOCAL_MACHINE,
                L"System\\CurrentControlSet\\Control\\Session Manager\\Environment",
                TRUE,
                KEY_WRITE))
            {
                bReturn = reg.WriteExpandString(lpVarName, lpVar);
                reg.Close();
            }
            return bReturn;
        }
Пример #3
0
        static BOOL _DelUserEnv(LPCTSTR lpVarName)
        {
            BOOL bReturn = FALSE;

            CString sSid;
            if (ZLUsid::GetCurrentUserSID(sSid))
            {
                CString sSubKey = sSid + L"\\Environment";
                ZLRegister reg;
                if (reg.Open(HKEY_USERS, sSubKey, FALSE, KEY_WRITE))
                {
                    bReturn = reg.DeleteValue(lpVarName);
                    reg.Close();
                }
            }
            return bReturn;
        }
Пример #4
0
        static BOOL _AddUserEnv(LPCTSTR lpVarName, LPCTSTR lpVar)
        {
            BOOL bReturn = FALSE;

            CString sSid;
            if (ZLUsid::GetCurrentUserSID(sSid))
            {
                CString sSubKey = sSid + L"\\Environment";
                ZLRegister reg;
                if (reg.Open(HKEY_USERS, sSubKey, TRUE, KEY_WRITE))
                {
                    bReturn = reg.WriteExpandString(lpVarName, lpVar);
                    reg.Close();
                }
            }
            return bReturn;
        }