← Retour au blog
tech 10 September 2026

The Algorithm Behind Choosing the Initial User Picture in Windows XP

Discover how Windows XP used the RtlRandomEx random number generator to select your initial user picture. A practical case of reservoir sampling.

Article inspired by the original source
What algorithm did Windows XP use to choose your initial user picture? ↗ devblogs.microsoft.com

Introduction

Released in 2001, Windows XP was a hallmark of simplicity and user-friendly design. One intriguing detail of this operating system is how it chose the initial user picture when creating an account. Behind this seemingly simple feature is an elegant algorithm using the RtlRandomEx random number generator.

The RtlRandomEx Random Number Generator

The algorithm Windows XP used to select the initial user picture relies on RtlRandomEx, a random number generator. It uses the current value of GetTickCount() as the initial seed. This means the picture selection was influenced by the time elapsed since the system last booted.

Why Use RtlRandomEx?

RtlRandomEx was chosen for its ability to provide a uniform distribution and its performance efficiency. Unlike other methods requiring multiple passes over a data collection, RtlRandomEx allows for single-pass selection.

The One-Pass Selection Algorithm

Windows XP employed a variant of the reservoir sampling algorithm, where k equals 1. This simplified algorithm allows for choosing a random item from a data stream without knowing its total size upfront. Here’s how it works:

``javascript selectRandomFromIterator(iterator) { var count = 0; var winner = null; while (iterator.moveNext()) { ++count; if (uniform_random(min: 1, max: count) == count) { winner = iterator.current(); } } return winner; } ``

This algorithm ensures that each picture in the user account pictures directory has an equal chance of being selected.

Advantages of the Algorithm

Using a one-pass selection algorithm offers several benefits:

  1. Efficiency: Reduces file system calls, thus minimizing bottlenecks.
  2. Simplicity: No need to handle changes in the directory during execution.
  3. Uniformity: Ensures equal probability distribution for selection.

Modern Use Cases

Although this algorithm was used over two decades ago, its principles can be applied to modern challenges, such as real-time data stream processing or sampling from large databases.

Conclusion

The user picture selection algorithm in Windows XP is a fascinating example of practical application of probabilistic programming concepts. By adopting efficient and straightforward solutions, complex problems can be solved in constrained environments.

Let's discuss your project in 15 minutes.

Windows XP RtlRandomEx user picture reservoir sampling algorithm
Deepthix newsletter · 100% AI · every Monday 8am

An AI agent reads tech for you.

Our AI agent scans ~200 sources per week and ships the best articles to your inbox Monday 8am. Free. One click to unsubscribe.

Visit the newsletter page →

Want to automate your operations?

Let's talk about your project in 15 minutes.

Book a call