GateKeeper.cpp
branchCOM-115
changeset 428 59bc6114c932
parent 380 4093982a8fe9
child 429 2e8e6705baa0
     1.1 --- a/GateKeeper.cpp	Thu Jul 02 20:20:56 2020 +0200
     1.2 +++ b/GateKeeper.cpp	Thu Jul 02 22:47:58 2020 +0200
     1.3 @@ -182,7 +182,8 @@
     1.4  
     1.5              if (now > next) {
     1.6                  next = now + GateKeeper::cycle;
     1.7 -                keep_updated();
     1.8 +                if (update_enabled())
     1.9 +                    keep_updated();
    1.10              }
    1.11  
    1.12              Sleep(waiting);
    1.13 @@ -344,6 +345,41 @@
    1.14          return result;
    1.15      }
    1.16  
    1.17 +    void GateKeeper::enable_update()
    1.18 +    {
    1.19 +        LONG lResult = RegOpenKeyEx(cu, updater_reg_path, 0, KEY_WRITE, &hkUpdater);
    1.20 +        if (lResult != ERROR_SUCCESS)
    1.21 +            return;
    1.22 +
    1.23 +        lResult = RegSetValueExW(hkUpdater, NULL, 0, REG_SZ, (const BYTE *) _T("1"), sizeof(TCHAR)*2);
    1.24 +    }
    1.25 +
    1.26 +    void GateKeeper::disable_update()
    1.27 +    {
    1.28 +        LONG lResult = RegOpenKeyEx(cu, updater_reg_path, 0, KEY_WRITE, &hkUpdater);
    1.29 +        if (lResult != ERROR_SUCCESS)
    1.30 +            return;
    1.31 +
    1.32 +        lResult = RegSetValueEx(hkUpdater, NULL, 0, REG_SZ, (const BYTE *) _T("0"), sizeof(TCHAR) * 2);
    1.33 +    }
    1.34 +
    1.35 +    bool GateKeeper::update_enabled()
    1.36 +    {
    1.37 +        bool enabled = true;
    1.38 +
    1.39 +        DWORD esize;
    1.40 +        RegGetValue(cu, updater_reg_path, NULL, RRF_RT_REG_SZ, NULL, NULL, &esize);
    1.41 +        if (esize) {
    1.42 +            TCHAR* edata = new TCHAR[esize];
    1.43 +            RegGetValue(cu, updater_reg_path, NULL, RRF_RT_REG_SZ, NULL, edata, &esize);
    1.44 +            if (tstring(edata) == _T("0"))
    1.45 +                enabled = false;
    1.46 +            delete[] edata;
    1.47 +        }
    1.48 +
    1.49 +        return enabled;
    1.50 +    }
    1.51 +
    1.52      GateKeeper::product_list GateKeeper::registered_products()
    1.53      {
    1.54          product_list products;