microsoft / microsoft/microsoft-ui-xaml

Packaged wasdk app can't even read correct registry value?

Open
#10,971 13 comments 0 reactions 0 assignees View on GitHub
area-External feature proposal needs-triage
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

So I am using `RegGetValue()` to poll registry values. And when changes are made to the value, the polling result returned is completely unpredictable in wasdk packaged app

### Steps to reproduce the bug

1. Create a C++ winui3 packaged app (without a Windows application packaging project)
2. Add this code in `MainWindow.xaml` constructor
```cpp
MainWindow()
{
std::thread{ [] {
while (true)
{
DWORD value;
DWORD size = sizeof(value);
RegGetValueW(
HKEY_CURRENT_USER,
LR"(Software\Microsoft\Windows\DWM)",
L"AccentColor",
RRF_RT_REG_DWORD,
nullptr,
&value,
&size
);
OutputDebugString(std::format(L"{}\n", value).data());
Sleep(1000);
}
} }.detach();
}
```
3. Use the same code in a C++ console application project
4. Build and run both, now go to windows personalization settings, change the accent color, observe the output from both. See how they diverge. Open up a `regedit` you can see the console application is returning the correct result.

### Expected behavior

_No response_

### Screenshots

![Image](https://github.com/user-attachments/assets/63cb40c0-b6bf-46aa-b283-6de8fc05d481)

### NuGet package version

Windows App SDK 1.6.3: 1.6.250108002

### Packaging type

Packaged (MSIX)

### Windows version

Windows 11 version 24H2 (22621, October 2024 Update)

### IDE

Visual Studio 2022

### Additional context

At this point, I don't even know what to expect. I thought at least polling should work for me to workaround #4075

[Repro](https://github.com/HO-COOH/WinUI-Bug/tree/main/27-PackagedAppReadIncorrectRegistryValue)

Contributor guide

Open the contributing guide

Research direction

Start with the linked WinUI-Bug repro, especially the packaged C++ app and the RegGetValueW call in the MainWindow.xaml constructor. Compare its registry polling output with the console application while changing the Windows accent color, then determine whether the packaged result can be made consistent or whether the behavior should be documented as a limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.