How Windows XP randomly picked your default profile photo

Windows XP didn't just roll a simple die to pick your account picture—it used a clever computer science shortcut.

Longtime Microsoft engineer Raymond Chen detailed how Windows XP selected profile photos for new accounts. The OS pulled files from the default pictures directory using the RtlRandomEx function, seeded by system uptime via GetTickCount(). Instead of scanning the folder twice to count files and pick one, it used a single-pass algorithm called reservoir sampling.

Why it matters: Disk access was a massive bottleneck in 2001. Skipping the second file-system check saved slow disk reads and prevented errors if files changed mid-scan. Microsoft also added a hard safety cap at 100 pictures so the OS wouldn't freeze if someone dumped a million photos into the folder.

Know this: The math works by giving the n-th picture a 1/n chance to beat the current winner. Every photo gets an equal shot on a single run through the folder, without the OS ever needing to count the total first.

Proof that even a default profile photo had thoughtful engineering behind it.