Win32 Desktop Applications Calling WinRT APIs on Windows 8: Which Contracts Cross the Boundary
0 reputation · 19 Sept 2026, 01:29 UTC
0 reputation · 19 Sept 2026, 01:29 UTC
I am designing an application for Windows 8 where a traditional Win32 desktop process needs to consume functionality that appears to exist only in the Windows Runtime (WinRT) surface, such as the share contract or certain system settings exposed through the Charm bar. The documented model states that desktop apps may call a subset of WinRT APIs, while Store apps are restricted from direct Win32 access, but the exact subset and the activation requirements are unclear to me.
The target is Windows 8 (not 8.1), so behaviors added in 8.1 such as boot-to-desktop are out of scope. I need to know whether a plain, unpackaged Win32 executable can activate WinRT components that assume an app-container identity, and whether contract-based features like Share require the calling app to participate in the Modern UI lifecycle rather than running as a background desktop process.
Given the asymmetric interop rules, I am unsure which side of the boundary should own the feature.
On Windows 8, unpackaged Win32 desktop processes can call a limited subset of WinRT APIs, but cannot participate in contract-based features like Share. The key distinction is between system-level APIs (accessible) and app-model-dependent APIs (restricted).
Windows.System.Diagnostics, basic Windows.Storage (local folders), Windows.ApplicationModel.UserDataAccountsWindows.Devices.Enumeration for local hardware, basic Windows.Devices.GeolocationWindows.Networking for hostname resolution, basic connection APIsWindows.ApplicationModel.Activation, background task registrationWindows.UI.Xaml, Windows.UI.ViewManagementA plain Win32 executable cannot act as a Share source or target. The contract system requires:
Calling certain WinRT APIs from desktop code may trigger a partial Modern UI transition:
Windows.Storage.Pickers.FileOpenPicker may show picker UIWindows.System.LauncherOptions may activate Charms barTo call WinRT from Win32 on Windows 8:
Windows.lib or C# with System.Runtime.InteropServices.WindowsRuntimeRoInitialize (C++) or let the runtime auto-initialize (C#)RPC_E_WRONG_THREAD by marshaling to UI thread for UI APIsVerification test: Run this from a Win32 console app on Windows 8:
#include <windows.h>
#include <winrt/Windows.Storage.h>
int main() {
auto folder = Windows::Storage::ApplicationData::Current().LocalFolder();
printf("Local folder path: %ws\n", folder.Path().Data());
return 0;
}
This should succeed. Attempting to create a ShareProvider will fail with E_ACCESSDENIED.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.