Printing a file in Windows App SDK (tested printing thought processstartinfo with verb print) its not working

Vignesh Govindhan 26 Reputation points
2021-10-28T06:33:30.687+00:00

I am migrating my app from UWP to WinUI 3 in Desktop with windows app sdk. I used to print using print manager in uwp.

So printing a file in Windows App SDK by printing thought processstartinfo with verb "print" its not working. is this a right way to print or are they any API's specific to Windows App SDK

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
727 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 81,836 Reputation points
    2021-10-28T08:50:21.153+00:00

    This test with a "e:\test.txt" file works for me in a Windows App SDK C++ Desktop app :

    At beginning :

    #pragma comment (lib, "Shell32")
    

    Then :

    ShellExecute(0, L"open", L"rundll32.exe", L"C:\\windows\\system32\\mshtml.dll, PrintHTML \"e:\\test.txt\"", NULL, SW_SHOWNORMAL);
    

    ("print" or "printto" verbs with the file instead of "open" can also be used, but it depends on registry associations)

    0 comments No comments