UWP error 0x80270254
On latest Win11, When call IApplicationActivationManager interface method ActivateForFile to start uwp application with file argument, it always return 0x80270254 error code. Anyone know why?
Windows
通用 Windows 平台 (UWP)
Windows API - Win32
-
Junjie Zhu - MSFT 19,316 信誉分 • Microsoft 供应商
2024-08-15T09:51:26.3266667+00:00 Hi @Jarvis Xie ,
Welcome to Microsoft Q&A!
Could you please provide a minimal-reproducible-example to help us further check the problem for you? and which version of win11 is it?
Thank you.
-
Jarvis Xie 0 信誉分
2024-08-16T01:41:46.3766667+00:00 Hi Zhu:
This is the simple example to reproduce the issue.
BOOL StartUWP(const wstring& wsUserAppId, const wstring& wsFilePath)
{
HRESULT hRet = S_FALSE; HRESULT result = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); if (SUCCEEDED(result)) { CComPtr<IApplicationActivationManager> spAppActivationManager; result = CoCreateInstance(CLSID_ApplicationActivationManager, NULL, CLSCTX_LOCAL_SERVER, IID_IApplicationActivationManager, (LPVOID*)&spAppActivationManager); if (SUCCEEDED(result)) { DWORD dwProcessId; IShellItem* pShellItem = NULL; IShellItemArray* pShellItemArray = NULL; result = ::CoAllowSetForegroundWindow( spAppActivationManager, nullptr); do { HRESULT hr = SHCreateItemFromParsingName(wsFilePath.c_str(), NULL, IID_PPV_ARGS(&pShellItem)); if (hr != S_OK || pShellItem == NULL) { break; } hr = SHCreateShellItemArrayFromShellItem(pShellItem, IID_IShellItemArray, (VOID**)&pShellItemArray); if (hr != S_OK || pShellItemArray == NULL) { break; } hr = spAppActivationManager->ActivateForFile(wsUserAppId.c_str(), pShellItemArray, NULL, &dwProcessId); if (FAILED(hr)) { break; } } while (FALSE); } CoUninitialize(); } return TRUE;
}
void TestStartUWP()
{
// This call would failed, ActivateForFile return 0x80270254. StartUWP(L"Microsoft.Windows.Photos_8wekyb3d8bbwe!App", L"C:\\Test\\Test.png"); // This call successful. StartUWP(L"Microsoft.ZuneVideo_8wekyb3d8bbwe!Microsoft.ZuneVideo", L"C:\\Test\\Test.mp4");
}
After analysis, I found that the reason for the failure is due to the new version of Win11(23H2,22631.4037)'s registry HKEY_CLASSES_ROOT\Extensions\ContractId\Windows.File\PackageId have no Photos node, while old versions Win11 have.
I have roughly understood that the new version of Win11's Photos no longer supports calling IApplication Activation Manager's ActiveForFile to open files, But Windows Explorer support launch Photos with file. So I want to know does Windows support other programing method open Photos(UWP) with file argument?
-
Jarvis Xie 0 信誉分
2024-08-16T04:15:27.5466667+00:00 Please refer to my problem's details, Thanks!
-
Junjie Zhu - MSFT 19,316 信誉分 • Microsoft 供应商
2024-08-16T08:03:02.33+00:00 Hi @Jarvis Xie ,
I can reproduce same behavior on Win11 22H2. This is indeed an unexpected behavior on win11. As a workaround, you can useProcess.Start
orShellExecute
to open the image.
For your scenario, if this unexpected behavior has a serious business impact, I suggest that you might need to open a support ticket for this. Please contact our paid support at MS Support. You will get 1:1 support on that. Select Developer Tools -> Windows SDK -> Windows SDK for Windows 10 ->Desktop app UI development-> Windows Shell API in the support page and you could contact the team. Please kindly note that your support ticket will be free if it is Microsoft's issue.If this behavior has little impact, we recommend that you submit this behavior in Feedback Hub. You could find the Feedback Hub in the Start Menu. Please select Developer Platform->API Feedback as the category when you submit your request. The related team will check the request. After you submit the request, please share your link, I will help you submit this request as well.
Thank you.
-
Jarvis Xie 0 信誉分
2024-08-16T09:23:56.1533333+00:00 Thanks for you reply, I have try Process.Start and ShellExecute in desktop windows application to start the UWP application, The Photos.exe can startup, but it would crashed.
-
Junjie Zhu - MSFT 19,316 信誉分 • Microsoft 供应商
2024-08-16T09:52:45.45+00:00 Hi @Jarvis Xie ,
Yes, they can't open UWP apps. If this unexpected behavior has a serious business impact, I suggest that you need to open a support ticket. Please kindly note that your support ticket will be free if it is Microsoft's issue.
登录以评论