WinUI3 : Understanding WinUI3 desktop app

21939029 966 Reputation points


As we can create a WinUI3 app in both the desktop app(win32 app) and the UWP app. What exactly does it mean to create a WinUI3 in a desktop app? As I understand, this app will follow the Win32 App model, that is, the app will not run on sandbox and the app will not have activation and lifecycle management like UWP apps. Is this right?

In this case, How can we use Win32 APIs in this project, and how can we follow the event loop like the WNDPROC callback function instead of Application::Start()?

Thank You

Universal Windows Platform (UWP)
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.
512 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,072 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 71,866 Reputation points

    Application::Start replaces the main message loop
    As it is a Win32 app, you can have access to the main window WndProc with SetWindowSubclass (for example in some samples I posted in C#, like in MainWindow.xaml.cs, where I needed to intercept particular messages)

    I have this wWinMain in the C++ generated code :

    int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)  
            void (WINAPI *pfnXamlCheckProcessRequirements)();  
            auto module = ::LoadLibrary(L"Microsoft.ui.xaml.dll");  
            if (module)  
                pfnXamlCheckProcessRequirements = reinterpret_cast<decltype(pfnXamlCheckProcessRequirements)>(GetProcAddress(module, "XamlCheckProcessRequirements"));  
                if (pfnXamlCheckProcessRequirements)  
        return 0;  

0 additional answers

Sort by: Most helpful