question

HillTim-1836 avatar image
0 Votes"
HillTim-1836 asked ·

Is the OCR API supported from Win32 Applications without package identity?

I am trying to use the UWP OCR API from a Win32 application. https://docs.microsoft.com/en-us/uwp/api/windows.media.ocr.ocrengine

I've succeeded in actually using it using it from both C#: https://blogs.windows.com/windowsdeveloper/2019/04/30/calling-windows-10-apis-from-a-desktop-application-just-got-easier/ and C++ using C++/WinRT https://www.nuget.org/packages/Microsoft.Windows.CppWinRT/2.0.191217.1 in a Win32 application.

However, I cannot tell if this is or should be a supported scenario, or whether the documentation is up to date and accurate.

According to: https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-supported-api

Windows.Media.Ocr.OcrEngine Windows.Media.Ocr.OcrLine Windows.Media.Ocr.OcrResult Windows.Media.Ocr.OcrWord

are "APIs supported only in apps with package identity". However there is also this vague note:

"Occasionally, APIs in these areas may appear to function correctly. However, if an API is not explicitly listed as supported, you should avoid using it as it may have unintended side effects or behavior. Support for these APIs may become available in future releases. In the interim, your app should use relevant Win32 or .NET APIs instead."

Of course, there are no Win32 OCR apis....

There was a sample app available at some point but it was removed for some reason: https://github.com/microsoft/cppwinrt/tree/february_2017_refresh/10.0.15042.0/Samples/Ocr

uwp
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

FayWang-MSFT avatar image
0 Votes"
FayWang-MSFT answered ·

Hello,

​Welcome to Microsoft Q&A!

From APIs supported only in apps with package identity, OCR API indeed requires package identity. And there are remarks mentioning that it may also take effect in other cases. So according to this document, it's better to package your win32 application into msix mode. Since when you package it in an MSIX package, it will grant package identity to a desktop app.

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.