⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slayer.c

📁 winNT技术操作系统,国外开放的原代码和LIUX一样
💻 C
📖 第 1 页 / 共 3 页
字号:
    SendMessage(hListBox,
                LB_RESETCONTENT,
                0,
                0);

    for (item = info->CItems, i = 0;
         item != NULL;
         item = item->next, i++)
    {
        SendMessage(hListBox,
                    LB_ADDSTRING,
                    0,
                    (LPARAM)item->szName);
    }

    if (bDisableControlsIfEmpty)
    {
    }
}

static INT_PTR CALLBACK
EditCompatibilityModesProc(HWND hwndDlg,
                           UINT uMsg,
                           WPARAM wParam,
                           LPARAM lParam)
{
    LPCOMPATIBILITYPAGE this;

    switch (uMsg)
    {
        case WM_COMMAND:
        {
            switch(LOWORD(wParam))
            {
                case IDOK:
                    EndDialog(hwndDlg,
                              IDOK);
                    break;

                case IDCANCEL:
                    EndDialog(hwndDlg,
                              IDCANCEL);
                    break;
            }
            break;
        }

        case WM_CLOSE:
        {
            EndDialog(hwndDlg,
                      IDCANCEL);
            break;
        }

        case WM_INITDIALOG:
        {
            HWND hList = GetDlgItem(hwndDlg,
                                    IDC_COMPATIBILITYMODE);

            this = (LPCOMPATIBILITYPAGE)lParam;
            SetWindowLongPtr(hwndDlg,
                             GWLP_USERDATA,
                             (LONG_PTR)this);

            FillEditListBoxWithCompatibilityModes(this,
                                                  hwndDlg,
                                                  hList,
                                                  FALSE);
            break;
        }
    }

    return FALSE;
}

static VOID
InitializePage(LPCOMPATIBILITYPAGE this,
               HWND hwndDlg)
{
    HWND hList;

    LoadCompatibilityModes(this);

    /* initialize the controls */
    hList = GetDlgItem(hwndDlg,
                       IDC_COMPATIBILITYMODE);

    LoadAndParseAppCompatibilityFlags(this,
                                      this->szFile);
    FillComboBoxWithCompatibilityModes(this,
                                       hwndDlg,
                                       hList,
                                       TRUE,
                                       TRUE);
}

static VOID
ReportPropertyChange(LPCOMPATIBILITYPAGE this,
                     HWND hwndDlg)
{
    this->Changed = TRUE;

    SendMessage(GetParent(hwndDlg),
                PSM_CHANGED,
                (WPARAM)hwndDlg,
                0);
}

static BOOL
ComposeFlags(LPCOMPATIBILITYPAGE this,
             LPTSTR szFlags)
{
    if (this->CSelectedItem != NULL)
    {
        _tcscpy(szFlags,
                this->CSelectedItem->szKeyName);
        return TRUE;
    }

    return FALSE;
}

static BOOL
ApplySettings(LPCOMPATIBILITYPAGE this,
              HWND hwndDlg)
{
    HKEY hk;
    LONG e;
    TCHAR szFlags[256];
    BOOL enabled = IsDlgButtonChecked(hwndDlg,
                                      IDC_CHKRUNCOMPATIBILITY) == BST_CHECKED;
  
    if (enabled)
    {
        HWND hCombo = GetDlgItem(hwndDlg,
                                 IDC_COMPATIBILITYMODE);
        int index = (int)SendMessage(hCombo,
                                     CB_GETCURSEL,
                                     0,
                                     0);
        if (index >= 0)
        {
            int i;
            PCITEM sel = this->CItems;

            /* map the index to a CITEM structure */
            for(i = index;
                i > 0 && sel != NULL;
                i--)
            {
                sel = sel->next;
            }

            /* update the CSelectedItem member */
            this->CSelectedItem = sel;
        }
        else
            enabled = FALSE;
    }

    e = RegOpenKey(HKEY_CURRENT_USER,
                   TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),
                   &hk);
    if (e == ERROR_SUCCESS)
    {
        if (!enabled)
        {
            /* FIXME - only delete if nothing else is selected! */
            e = RegDeleteValue(hk,
                               this->szFile);
        }
        else
        {
            if (ComposeFlags(this,
                             szFlags))
            {
                e = RegSetValueEx(hk,
                                  this->szFile,
                                  0,
                                  REG_SZ,
                                  (LPBYTE)szFlags,
                                  (_tcslen(szFlags) + 1) * sizeof(TCHAR));
            }
            else
            {
                e = RegDeleteValue(hk,
                                   this->szFile);
            }
        }

        RegCloseKey(hk);
    }

    this->Changed = FALSE;
    return (e == ERROR_SUCCESS);
}

static INT_PTR CALLBACK
CompatibilityPageProc(HWND hwndDlg,
                      UINT uMsg,
                      WPARAM wParam,
                      LPARAM lParam)
{
    LPCOMPATIBILITYPAGE this = (LPCOMPATIBILITYPAGE)GetWindowLongPtr(hwndDlg,
                                                                     GWLP_USERDATA);

    switch (uMsg)
    {
        case WM_COMMAND:
        {
            if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_COMPATIBILITYMODE)
            {
                ReportPropertyChange(this,
                                     hwndDlg);
            }
            else
            {
                switch (LOWORD(wParam))
                {
                    case IDC_CHKRUNCOMPATIBILITY:
                    {
                        HWND hList = GetDlgItem(hwndDlg,
                                                IDC_COMPATIBILITYMODE);

                        if (hList != NULL)
                        {
                            EnableWindow(hList,
                                         IsDlgButtonChecked(hwndDlg,
                                                            IDC_CHKRUNCOMPATIBILITY) == BST_CHECKED);
                        }
                        /* fall through */
                    }

                    case IDC_CHKRUNIN256COLORS:
                    case IDC_CHKRUNIN640480RES:
                    case IDC_CHKDISABLEVISUALTHEMES:
                        ReportPropertyChange(this,
                                             hwndDlg);
                        break;

                    case IDC_EDITCOMPATIBILITYMODES:
                    {
                        if (DialogBoxParam(hInstance,
                                           MAKEINTRESOURCE(IDD_EDITCOMPATIBILITYMODES),
                                           hwndDlg,
                                           EditCompatibilityModesProc,
                                           (LPARAM)this) == IDOK)
                        {
                            InitializePage(this,
                                           hwndDlg);
                        }
                        break;
                    }
                }
            }
            break;
        }

        case WM_NOTIFY:
        {
            NMHDR *hdr = (NMHDR*)lParam;
            switch (hdr->code)
            {
                case PSN_APPLY:
                    if (this->Changed)
                    {
                        return ApplySettings(this,
                                             hwndDlg);
                    }
                    break;
            }
            break;
        }

        case WM_INITDIALOG:
        {
            LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam;
            this = (LPCOMPATIBILITYPAGE)psp->lParam;
            SetWindowLongPtr(hwndDlg,
                             GWLP_USERDATA,
                             (LONG_PTR)this);

            InitializePage(this,
                           hwndDlg);
            break;
        }
    }

    return FALSE;
}

static UINT CALLBACK
CompatibilityPageCallback(HWND hwnd,
                          UINT uMsg,
                          LPPROPSHEETPAGE ppsp)
{
    LPCOMPATIBILITYPAGE this = (LPCOMPATIBILITYPAGE)ppsp->lParam;

    switch (uMsg)
    {
        case PSPCB_CREATE:
            return TRUE;

        case PSPCB_RELEASE:
            ICompatibilityPage_fnRelease(this);
            return FALSE;

        default:
            return FALSE;
    }
}

static LPCOMPATIBILITYPAGE
ICompatibilityPage_fnConstructor(VOID)
{
    LPCOMPATIBILITYPAGE cp;

    cp = HeapAlloc(GetProcessHeap(),
                   HEAP_ZERO_MEMORY,
                   sizeof(COMPATIBILITYPAGE));
    if (cp != NULL)
    {
        cp->lpVtbl = &efvt;
        cp->lpVtbl->fn.IShellPropSheetExt = efvtIShellPropSheetExt;
        cp->ref = 1;
        InterlockedIncrement(&dllrefs);
    }

    return cp;
}

HRESULT STDMETHODCALLTYPE
ICompatibilityPage_fnQueryInterface(LPCOMPATIBILITYPAGE this,
                                    REFIID iid,
                                    PVOID *pvObject)
{
    if (IsEqualIID(iid,
                   &IID_IShellPropSheetExt))
    {
        this->lpVtbl->fn.IShellPropSheetExt = efvtIShellPropSheetExt;
        ICompatibilityPage_fnAddRef(this);
        *pvObject = this;
        return S_OK;
    }
    else if (IsEqualIID(iid,
                        &IID_IShellExtInit))
    {
        this->lpVtbl->fn.IShellExtInit = efvtIShellExtInit;
        ICompatibilityPage_fnAddRef(this);
        *pvObject = this;
        return S_OK;
    }
    else if (IsEqualIID(iid,
                        &IID_IClassFactory))
    {
        this->lpVtbl->fn.IClassFactory = efvtIClassFactory;
        ICompatibilityPage_fnAddRef(this);
        *pvObject = this;
        return S_OK;
    }
    else if (IsEqualIID(iid,
                        &IID_IUnknown))
    {
        ICompatibilityPage_fnAddRef(this);
        *pvObject = this;
        return S_OK;
    }

    *pvObject = NULL;
    return E_NOINTERFACE;
}

ULONG STDMETHODCALLTYPE
ICompatibilityPage_fnAddRef(LPCOMPATIBILITYPAGE this)
{
    return (ULONG)InterlockedIncrement(&this->ref);
}

ULONG STDMETHODCALLTYPE
ICompatibilityPage_fnRelease(LPCOMPATIBILITYPAGE this)
{
    ULONG rfc;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -