What algorithm did Windows XP use to choose your initial user picture? - The Old New Thing (http://gmpg.org/xfn/11) (https://devblogs.microsoft.com/oldnewthing/xmlrpc.php) (https://js.monitor.azure.com/) (https://browser.events.data.microsoft.com/) (index.html@p=112683.html) (The Old New Thing » What algorithm did Windows XP use to choose your initial user picture? Comments Feed) (https://devblogs.microsoft.com/oldnewthing/20260909-00/?p=112683/feed) (oEmbed (JSON)) (https://devblogs.microsoft.com/oldnewthing/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fdevblogs.microsoft.com%2Foldnewthing%2F20260909-00%2F%3Fp%3D112683) (oEmbed (XML)) (https://devblogs.microsoft.com/oldnewthing/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fdevblogs.microsoft.com%2Foldnewthing%2F20260909-00%2F%3Fp%3D112683&format=xml) (../wp-content/plugins/metronet-profile-picture/dist/blocks.style.build.css@ver=2.6.4.css) (../wp-content/plugins/metronet-profile-picture/dist/blocks.style.build.css@ver=2.6.4.css) (../wp-content/plugins/devblogs-lightbox/assets/css/lightbox.min.css@ver=1770924660.css) (../wp-content/plugins/devblogs-lightbox/assets/css/lightbox.min.css@ver=1770924660.css) (../wp-content/plugins/newsletter/style.css@ver=9.3.5.css) (../wp-content/plugins/newsletter/style.css@ver=9.3.5.css) (../wp-content/plugins/newsletter-country-sync/css/newsletter-style.css@ver=1770924660.css) (../wp-content/themes/devblogs-evo/css/theme.min.css@ver=1.4.0.1788284719.css) (../wp-content/themes/devblogs-evo/css/theme.min.css@ver=1.4.0.1788284719.css) (../wp-content/themes/devblogs-evo/css/lite-yt-embed.css@ver=0.3.8.css) (../wp-content/themes/devblogs-evo/css/lite-yt-embed.css@ver=0.3.8.css) (../wp-content/plugins/fabric-icon-manager/assets/css/fabric-icons.css@ver=1699358813.css) (../wp-content/plugins/fabric-icon-manager/assets/css/fabric-icons.css@ver=1699358813.css) (../wp-content/plugins/devblogs-comments-evo/admin/css/simplecomments.min.css@ver=1783529315.css) (../wp-includes/css/dashicons.min.css) (../wp-includes/css/dashicons.min.css) (../wp-includes/css/editor.min.css) (../wp-includes/css/editor.min.css) (../wp-content/plugins/devblogs-blocks/assets/block-custom.css) (../wp-content/plugins/devblogs-blocks/assets/block-custom.css) (../wp-content/plugins/devblogs-blocks/assets/highlight.min.css) (../wp-content/plugins/devblogs-blocks/assets/highlight.min.css) (https://devblogs.microsoft.com/oldnewthing/wp-json/) (JSON) (https://devblogs.microsoft.com/oldnewthing/wp-json/wp/v2/posts/112683) (RSD) (https://devblogs.microsoft.com/oldnewthing/xmlrpc.php?rsd) (https://devblogs.microsoft.com/oldnewthing/?p=112683) (../wp-content/uploads/sites/38/2021/03/Microsoft-Favicon.png) (../wp-content/uploads/sites/38/2021/03/Microsoft-Favicon.png) (../wp-content/uploads/sites/38/2021/03/Microsoft-Favicon.png) (../wp-includes/css/buttons.min.css) (../wp-includes/css/buttons.min.css) (index.html@p=112683.html#mainContent) Skip to main content (https://www.microsoft.com) (Microsoft) (https://devblogs.microsoft.com) Dev Blogs (https://devblogs.microsoft.com/ai) AI (https://devblogs.microsoft.com/dotnet/) All .NET posts (https://devblogs.microsoft.com/dotnet/category/maui/) .NET MAUI (https://devblogs.microsoft.com/dotnet/category/dotnet-aspire/) ASP.NET Core (https://devblogs.microsoft.com/dotnet/category/blazor/) Blazor (https://devblogs.microsoft.com/dotnet/category/entity-framework/) Entity Framework (https://devblogs.microsoft.com/cppblog/) C++ (https://devblogs.microsoft.com/dotnet/category/csharp/) C# (https://devblogs.microsoft.com/dotnet/category/fsharp/) F# (https://devblogs.microsoft.com/typescript/) TypeScript (https://devblogs.microsoft.com/dotnet/category/nuget/) NuGet (https://devblogs.microsoft.com/dotnet/category/maintenance-and-updates/) Servicing (https://devblogs.microsoft.com/dotnet-ch/) .NET Blog in Chinese (https://developer.microsoft.com/blog) Microsoft for Developers (https://devblogs.microsoft.com/agent-framework/) Agent Framework (https://devblogs.microsoft.com/develop-from-the-cloud/) Develop from the cloud (https://devblogs.microsoft.com/xcode/) Xcode (https://devblogs.microsoft.com/ise/) ISE Developer (https://devblogs.microsoft.com/typescript/) TypeScript (https://devblogs.microsoft.com/powershell/) PowerShell (https://devblogs.microsoft.com/python/) Python (https://devblogs.microsoft.com/java/) Java (https://devblogs.microsoft.com/java-ch/) Java Blog in Chinese (https://devblogs.microsoft.com/go/) Go (https://blogs.windows.com/msedgedev/) Microsoft Edge Dev (https://devblogs.microsoft.com/microsoft365dev/) Microsoft 365 Developer (https://devblogs.microsoft.com/identity/) Microsoft Entra Identity Developer (https://devblogs.microsoft.com/entrapowershell/) Microsoft Entra PowerShell (https://devblogs.microsoft.com/visualstudio/) Visual Studio (https://devblogs.microsoft.com/vscode-blog) Visual Studio Code (https://devblogs.microsoft.com/aspire/) Aspire (https://devblogs.microsoft.com/all-things-azure/) All things Azure (https://devblogs.microsoft.com/azure-sdk/) Azure SDK (https://devblogs.microsoft.com/azure-vm-runtime/) Azure VM Runtime Team (https://azure.microsoft.com/blog/) Microsoft Azure (https://devblogs.microsoft.com/cosmosdb/) Azure Cosmos DB (https://devblogs.microsoft.com/documentdb/) Azure DocumentDB (https://cloudblogs.microsoft.com/sqlserver/?product=azure-data-studio) Azure Data Studio (https://devblogs.microsoft.com/azure-sql/) Azure SQL (https://devblogs.microsoft.com/devops/) DevOps (https://devblogs.microsoft.com/directx/) DirectX (https://devblogs.microsoft.com/foundry/) Microsoft Foundry (https://devblogs.microsoft.com/powerplatform/) Power Platform (https://devblogs.microsoft.com/odata/) OData (https://devblogs.microsoft.com/udm/) Unified Data Model (IDEAs) (https://devblogs.microsoft.com/commandline/) Windows Command Line (https://devblogs.microsoft.com/ifdef-windows/) #ifdef Windows (https://devblogs.microsoft.com/insidemsix/) Inside MSIX (https://devblogs.microsoft.com/windows-music-dev/) MIDI and music (https://devblogs.microsoft.com/react-native/) React Native (https://devblogs.microsoft.com/oldnewthing/) The Old New Thing (https://blogs.windows.com/windowsdeveloper/) Windows Developer (Search) (../../../uhf.microsoft.com/statics/20260701.14.10/css/style-BpBYj3rT.css) (https://devblogs.microsoft.com/) Dev Blogs (https://devblogs.microsoft.com/oldnewthing/) The Old New Thing What algorithm did Windows XP use to choose your initial user picture? September 9th, 2026 (heart) 1 reaction What algorithm did Windows XP use to choose your initial user picture? () (https://devblogs.microsoft.com/oldnewthing/author/oldnewthing) Raymond Chen Show more I noted some time ago that (The martial arts logon picture) (https://devblogs.microsoft.com/oldnewthing/20040401-00/?p=39933) Windows XP chose your initial picture at random from among the pictures in the %ALLUSERSPROFILE%\ Application Data\ Microsoft\ User Account Pictures\ Default Pictures directory. But it seems people want to know more. Has anyone attempted to figure out the RNG for how Windows XP determines what profile picture is used on first account creation? — Xeno (@XenoPanther) (https://twitter.com/XenoPanther/status/1999217479923413284) December 11, 2025 The random number generator is our friend RtlRandomEx , using the current value of GetTickCount() as the initial seed. The function uses a one-pass random selection algorithm. I can immediately think of two benefits of this decision. First, compared to the naïve two-pass algorithm of counting up all the items, then randomly picking a number from 1 to n , and then iterating a second time to find the item at that index, it’s more efficient because it reduces the amount of calls into the file system, which is where the bottleneck is. Furthermore, the one-pass algorithm avoids complications if the number of files in the directory changes while the code is running. The one-pass algorithm is a special case of (https://en.wikipedia.org/wiki/Reservoir_sampling) reservoir sampling , where k is 1. This special case permits a tailored algorithm that is much simpler. 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; } The way this algorithm works is by observing that in a collection of n items, the last item has a 1/n chance of being randomly selected. If it isn’t selected, then you need to select randomly from the first n − 1 items, which you can solve recursively. Playing the recursion forward, you start with the base case which is that if you have a list of 1 item, then your only choice is to chose that item. Otherwise, if you have a list of n items, first choose an item randomly from the first n − 1, and then switch to the n th item with a 1/n probability. As a final safety check, the code stops after sampling 100 pictures. This avoids pathological behavior if somebody puts a million files in the Default Pictures directory. (Sign in to react) (https://devblogs.microsoft.com/oldnewthing/wp-login.php?redirect_to=https%3A%2F%2Fdevblogs.microsoft.com%2Foldnewthing%2F20260909-00%2F%3Fp%3D112683) 1 () () () () () () (Go to comments section) (index.html@p=112683.html#comments) 0 (Share this post) 0 (https://www.facebook.com/sharer/sharer.php?u=https://devblogs.microsoft.com/oldnewthing/20260909-00/?p=112683) (Share on Facebook) (Facebook) Share on Facebook (https://twitter.com/intent/tweet?url=https://devblogs.microsoft.com/oldnewthing/20260909-00/?p=112683&text=What algorithm did Windows XP use to choose your initial user picture?) (Share on X) Share on X (https://www.linkedin.com/shareArticle?mini=true&url=https://devblogs.microsoft.com/oldnewthing/20260909-00/?p=112683) (Share on LinkedIn) (LinkedIn) Share on Linkedin Category (https://devblogs.microsoft.com/oldnewthing/category/oldnewthing) Old New Thing Topics (https://devblogs.microsoft.com/oldnewthing/tag/history) History Share (https://www.facebook.com/sharer/sharer.php?u=https://devblogs.microsoft.com/oldnewthing/20260909-00/?p=112683) (https://twitter.com/intent/tweet?url=https://devblogs.microsoft.com/oldnewthing/20260909-00/?p=112683&text=What algorithm did Windows XP use to choose your initial user picture?) (https://www.linkedin.com/shareArticle?mini=true&url=https://devblogs.microsoft.com/oldnewthing/20260909-00/?p=112683) Author (Raymond Chen) (https://devblogs.microsoft.com/oldnewthing/author/oldnewthing) Raymond Chen Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information. 0 comments Be the first to start the discussion. (Leave a comment) Leave a comment (index.html@p=112683.html#respond) Cancel reply (https://devblogs.microsoft.com/oldnewthing/wp-login.php?redirect_to=https%3A%2F%2Fdevblogs.microsoft.com%2Foldnewthing%2F20260909-00%2F%3Fp%3D112683%23comments) Sign in (Reply) (Cancel) (112683) (0) (https://aka.ms/msftqacodeconduct) Code of Conduct (ad7af05511) Read next September 8, 2026 (https://devblogs.microsoft.com/oldnewthing/20260908-00/?p=112679) A sample use of the winstart.bat file in Windows 95 () Raymond Chen August 25, 2026 (https://devblogs.microsoft.com/oldnewthing/20260825-00/?p=112645) Why didn’t the Windows Entertainment Pack just run the MS-DOS version inside an emulator? () Raymond Chen Stay informed Get notified when new posts are published. () Email * (Enter your email) Country/Region * () Select... United States Afghanistan Åland Islands Albania Algeria American Samoa Andorra Angola Anguilla Antarctica Antigua and Barbuda Argentina Armenia Aruba Australia Austria Azerbaijan Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia Bonaire Bosnia and Herzegovina Botswana Bouvet Island Brazil British Indian Ocean Territory British Virgin Islands Brunei Bulgaria Burkina Faso Burundi Cabo Verde Cambodia Cameroon Canada Cayman Islands Central African Republic Chad Chile China Christmas Island Cocos (Keeling) Islands Colombia Comoros Congo Congo (DRC) Cook Islands Costa Rica Côte dIvoire Croatia Curaçao Cyprus Czechia Denmark Djibouti Dominica Dominican Republic Ecuador Egypt El Salvador Equatorial Guinea Eritrea Estonia Eswatini Ethiopia Falkland Islands Faroe Islands Fiji Finland France French Guiana French Polynesia French Southern Territories Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guernsey Guinea Guinea-Bissau Guyana Haiti Heard Island and McDonald Islands Honduras Hong Kong SAR Hungary Iceland India Indonesia Iraq Ireland Isle of Man Israel Italy Jamaica Jan Mayen Japan Jersey Jordan Kazakhstan Kenya Kiribati Korea Kosovo Kuwait Kyrgyzstan Laos Latvia Lebanon Lesotho Liberia Libya Liechtenstein Lithuania Luxembourg Macau SAR Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia Moldova Monaco Mongolia Montenegro Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands New Caledonia New Zealand Nicaragua Niger Nigeria Niue Norfolk Island North Macedonia Northern Mariana Islands Norway Oman Pakistan Palau Palestinian Authority Panama Papua New Guinea Paraguay Peru Philippines Pitcairn Islands Poland Portugal Puerto Rico Qatar Réunion Romania Rwanda Saba Saint Barthélemy Saint Kitts and Nevis Saint Lucia Saint Martin Saint Pierre and Miquelon Saint Vincent and the Grenadines Samoa San Marino São Tomé and Príncipe Saudi Arabia Senegal Serbia Seychelles Sierra Leone Singapore Sint Eustatius Sint Maarten Slovakia Slovenia Solomon Islands Somalia South Africa South Georgia and South Sandwich Islands South Sudan Spain Sri Lanka St Helena Ascension Tristan da Cunha Suriname Svalbard Sweden Switzerland Taiwan Tajikistan Tanzania Thailand Timor-Leste Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu U.S. Outlying Islands U.S. Virgin Islands Uganda Ukraine United Arab Emirates United Kingdom Uruguay Uzbekistan Vanuatu Vatican City Venezuela Vietnam Wallis and Futuna Yemen Zambia Zimbabwe I would like to receive the The Old New Thing Newsletter. (https://go.microsoft.com/fwlink/?LinkId=521839) Privacy Statement. (Subscribe) Subscribe Follow this blog (twitter) (https://twitter.com/ChenCravat) (youtube) (https://www.youtube.com/playlist?list=PLlrxD0HtieHge3_8Dm48C0Ns61I6bHThc) (youtube) (GitHub) (https://github.com/oldnewthing) (RSS Feed) (https://devblogs.microsoft.com/oldnewthing/feed/) Are you sure you wish to delete this comment? OK Cancel (https://devblogs.microsoft.com/oldnewthing/wp-login.php?redirect_to=https%3A%2F%2Fdevblogs.microsoft.com%2Foldnewthing%2F20260909-00%2F%3Fp%3D112683) Sign in Theme (08ab523625) Insert/edit link Close Enter the destination URL URL Link Text Open link in a new tab Or link to existing content Search No search term specified. Showing recent items. Search or use up and down arrow keys to select an item. Cancel (Add Link) Code Block × Paste your code snippet Ok Cancel (https://www.microsoft.com/surface/devices/surface-pro) Surface Pro (https://www.microsoft.com/surface/devices/surface-laptop) Surface Laptop (https://www.microsoft.com/en-us/surface/devices/surface-laptop-ultra?icid=DSM_Footer_WhatsNew_SurfaceLaptopUltra) Surface Laptop Ultra (https://www.microsoft.com/en-us/surface/devices/surface-rtx-spark-dev-box?icid=DSM_Footer_WhatsNew_SurfaceRTXSparkDevBox) Surface RTX Spark Dev Box (https://www.microsoft.com/en-us/microsoft-copilot/organizations?icid=DSM_Footer_CopilotOrganizations) Copilot for organizations (https://www.microsoft.com/en-us/microsoft-copilot/for-individuals?form=MY02PT&OCID=GE_web_Copilot_Free_868g3t5nj) Copilot for personal use (https://www.microsoft.com/en-us/microsoft-products-and-apps) Explore Microsoft products (https://www.microsoft.com/en-us/windows/apps-for-windows?icid=DSM_Footer_WhatsNew_Windows11apps) Windows 11 apps (https://account.microsoft.com/) Account profile (https://www.microsoft.com/en-us/download) Download Center (https://go.microsoft.com/fwlink/?linkid=2139749) Microsoft Store support (https://www.microsoft.com/en-us/store/b/returns) Returns (https://www.microsoft.com/en-us/store/b/order-tracking) Order tracking (https://www.microsoft.com/en-us/store/b/certified-refurbished-products) Certified Refurbished (https://www.microsoft.com/en-us/store/b/why-microsoft-store?icid=footer_why-msft-store_7102020) Microsoft Store Promise (https://www.microsoft.com/en-us/store/b/payment-financing-options?icid=footer_financing_vcc) Flexible Payments (https://www.microsoft.com/en-us/education) Microsoft in education (https://www.microsoft.com/en-us/education/devices/overview) Devices for education (https://www.microsoft.com/en-us/education/products/teams) Microsoft Teams for Education (https://www.microsoft.com/en-us/education/products/microsoft-365) Microsoft 365 Education (https://www.microsoft.com/education/how-to-buy) How to buy for your school (https://education.microsoft.com/) Educator training and development (https://www.microsoft.com/en-us/store/b/education) Deals for students and parents (https://www.microsoft.com/en-us/education/ai-in-education) AI for education (https://www.microsoft.com/en-us/ai?icid=DSM_Footer_AI) Microsoft AI (https://www.microsoft.com/en-us/security) Microsoft Security (https://www.microsoft.com/en-us/dynamics-365) Dynamics 365 (https://www.microsoft.com/en-us/microsoft-365/business) Microsoft 365 (https://www.microsoft.com/en-us/power-platform) Microsoft Power Platform (https://www.microsoft.com/en-us/microsoft-teams/group-chat-software) Microsoft Teams (https://www.microsoft.com/en-us/microsoft-365-copilot?icid=DSM_Footer_Microsoft365Copilot) Microsoft 365 Copilot (https://www.microsoft.com/en-us/store/b/business?icid=CNavBusinessStore) Small Business (https://azure.microsoft.com/en-us/) Azure (https://developer.microsoft.com/en-us/) Microsoft Developer (https://learn.microsoft.com/) Microsoft Learn (https://www.microsoft.com/software-development-companies/offers-benefits/isv-success?icid=DSM_Footer_SupportAIMarketplace&ocid=cmm3atxvn98) Support for AI marketplace apps (https://techcommunity.microsoft.com/) Microsoft Tech Community (https://marketplace.microsoft.com?icid=DSM_Footer_Marketplace&ocid=cmm3atxvn98) Microsoft Marketplace (https://www.microsoft.com/software-development-companies?icid=DSM_Footer_SoftwareCompanies&ocid=cmm3atxvn98) Software companies (https://visualstudio.microsoft.com/) Visual Studio (https://careers.microsoft.com/) Careers (https://www.microsoft.com/about) About Microsoft (https://news.microsoft.com/source/?icid=DSM_Footer_Company_CompanyNews) Company news (https://www.microsoft.com/en-us/privacy?icid=DSM_Footer_Company_Privacy) Privacy at Microsoft (https://www.microsoft.com/investor/default.aspx) Investors (https://www.microsoft.com/en-us/diversity/default?icid=DSM_Footer_Company_Diversity) Diversity and inclusion (https://www.microsoft.com/en-us/accessibility) Accessibility (https://www.microsoft.com/en-us/corporate-responsibility/sustainability?icid=DSM_Footer_Sustainability) Sustainability (https://aka.ms/yourcaliforniaprivacychoices) Your Privacy Choices Opt-Out Icon Your Privacy Choices (https://aka.ms/yourcaliforniaprivacychoices) Your Privacy Choices Opt-Out Icon Your Privacy Choices (https://go.microsoft.com/fwlink/?linkid=2259814) Consumer Health Privacy (https://www.microsoft.com/en-us/sitemap1.aspx) Sitemap (https://support.microsoft.com/contactus) Contact Microsoft (https://go.microsoft.com/fwlink/?LinkId=521839) Privacy (index.html@p=112683.html#) Manage cookies (https://go.microsoft.com/fwlink/?LinkID=206977) Terms of use (https://go.microsoft.com/fwlink/?linkid=2196228) Trademarks (https://go.microsoft.com/fwlink/?linkid=2196227) Safety & eco (https://www.microsoft.com/en-us/legal/compliance/recycling) Recycling (https://choice.microsoft.com) About our ads (index.html@p=112683.html#page) (Back to top)