microsoft / microsoft/Windows-classic-samples

IExecuteCommand Example Fails with "This app can't run on your PC"

Open
#242 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
5.7k
Forks
3.3k
PR merge metrics
No merged PRs in 30d

Description

When I try to clone, build and run the IExecuteCommand example using Visual Studio 2022 on Windows 10 Pro 21H2 64-bit, I get a handful of build errors that, even when worked around, result in something that doesn't work.

The first error that I get occurs when opening the .sln file in Visual Studio 2022. It's a warning that the solution file needs to be updated to work with 2022. The results of that seem to be favorable, and conversion is just a couple of clicks.
image
image

The second error that I get is related to type conversions in the following code from ShellHelpers.h:

__inline HRESULT SetItemImageImageInStaticControl(HWND hwndStatic, IShellItem *psi)
{
    HBITMAP hbmp = NULL;
    HRESULT hr = S_OK;
    if (psi)
    {
        IShellItemImageFactory *psiif;
        hr = psi->QueryInterface(IID_PPV_ARGS(&psiif));
        if (SUCCEEDED(hr))
        {
            RECT rc;
            GetWindowRect(hwndStatic, &rc);
            const UINT dxdy = min(rc.right - rc.left, rc.bottom - rc.top);    // make it square
            const SIZE size = { dxdy, dxdy };

            hr = psiif->GetImage(size, SIIGBF_RESIZETOFIT, &hbmp);
            psiif->Release();
        }
    }

image

I turned off "Treat warnings as errors" to get it to build:
image

By this point, the solution will build and run, producing the following dialog box:
image

Following those instructions, whenever I try to right click a .txt file and select the ExecuteCommand Verb Sample, like so:
image
I get the following error message:
image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the IExecuteCommand example under Samples/Win7Samples/winui/shell/appshellintegration/ExecuteCommandVerb and open its .sln in Visual Studio 2022. Reproduce the build errors, including the type-conversion issue reported in ShellHelpers.h, then verify the built sample can be registered and launched from the .txt file context menu without the reported Windows error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.