1

I need launch some console app from under my packaged Win32 app using microsoft WRL. But LaunchFullTrustProcessForCurrentAppAsync not work and HRESULT = 0x80010117 in async action completed callback.

using namespace Microsoft::WRL;
using namespace ABI::Windows::ApplicationModel;

void LaunchFullTrustApp() {
        ComPtr<IFullTrustProcessLauncherStatics> fullTrustProcessLauncherStatic;
        auto hr = RoGetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_FullTrustProcessLauncher).Get(), __uuidof(fullTrustProcessLauncherStatic), &fullTrustProcessLauncherStatic);
        CheckHr(hr);

        auto onCompletedCallback = Callback<Implements<RuntimeClassFlags<ClassicCom>, IAsyncActionCompletedHandler, FtmBase>>(
            [](IAsyncAction* asyncInfo, AsyncStatus asyncStatus)
            {
                auto hr = asyncInfo->GetResults();
                CheckHr(hr); // hr = "0x80010117: Call context cannot be accessed after call completed. CallContext: [\LaunchFullTrustProcessForApp] ..."

                if (asyncStatus != AsyncStatus::Completed) { // asyncStatus = Error
                    return S_FALSE;
                }

                return S_OK;
            });


        ComPtr<IAsyncAction> launchAction;
        hr = fullTrustProcessLauncherStatic->LaunchFullTrustProcessForCurrentAppAsync(&launchAction);
        CheckHr(hr);

        hr = launchAction->put_Completed(onCompletedCallback.Get());
        CheckHr(hr);
    }

Package manifest:

...
<Capabilities>
    <rescap:Capability Name="runFullTrust" />
</Capabilities>
...
<Extensions>
    <desktop:Extension Category="windows.fullTrustProcess" Executable="HelloWorld.exe" EntryPoint="Windows.FullTrustApplication" />
</Extensions>
isrepeat
  • 113
  • 5

0 Answers0