The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Jan 11, 2012
Post comments count 0
Post likes count 1

How can I detect the language a run of text is written in?

Raymond Chen

A customer asked, "I have a Unicode string. I want to know what language that string is in. Is there a function that can give me this information? I am most interested in knowing whether it is written in an East Asian language." The problem of determining the language in which a run of text is written is rather difficult. Many languages share the same script, or at least very similar scripts, so you can't just go based on which Unicode code point ranges appear in the string of text. (And what if the text contains words from multiple languages?) With heuristics and statistical analysis and a large enough sample, ...

Jan 10, 2012
Post comments count 0
Post likes count 1

News flash: Work-at-home job offers are mostly just scams

Raymond Chen

McClatchy Newspapers discovers, to everyone's surprise, that work-at-home job offers are mostly just scams. Of course, this is something Rob Cockerham discovered years ago. (He also has a rundown of all his articles on the subject, in case you haven't gotten enough.)

Jan 10, 2012
Post comments count 0
Post likes count 1

You can use backups for things other than restoring

Raymond Chen

A customer wanted to know the internal file format of Visual SourceSafe databases. (That wasn't the actual question, but I've translated it into something equivalent but which requires less explanation.) They explained why they wanted this information: We are doing some code engineering analysis on our project, so we need to extract data about every single commit to the project since its creation. Things like who did the commit, the number of lines of code changed, the time of day... We can then crank on all this data to determine things like What time of day are most bugs introduced? and possibly even try ident...

Jan 9, 2012
Post comments count 0
Post likes count 1

From the research journal Duh: To lose weight, eat less

Raymond Chen

Researchers have determined that the key to losing weight is to consume fewer calories. Okay, it's actually more interesting than the summary suggests. The researchers compared a variety of different popular diets and found that it didn't matter what diet you were on; the weight loss (and regain) was the same. The controlling factor was how many calories you consumed.

Jan 9, 2012
Post comments count 0
Post likes count 1

What were some of the abandoned features of Explorer back in its prototype days?

Raymond Chen

Chris asked for some stories about what Explorer was like in the early days. Well, one thing is that the original name of Explorer was Cabinet, continuing the folder/document metaphor by taking all your folders and documents and putting them inside a virtual filing cabinet. (Cabinet was viewed as an update to the Windows 3.1 File Manager program, whose icon as we all know was a filing cabinet.) Some remnants of this old name can be found in places like the structure. (Note that this old sense of Cabinet is unrelated to the CAB file format, which is also called Cabinet.) In the early versions of Cabinet,...

Jan 6, 2012
Post comments count 0
Post likes count 1

It must totally suck to live near Abbey Road

Raymond Chen

I feel sorry for the people who live near Abbey Road or who have to take that road as part of their daily routine, because tourists keep blocking traffic to recreate the cover of the eponymous Beatles album. The recording studio has a webcam on the intersection so you can watch the mayhem as it happens. Update: Just this morning, I checked out the webcam and within two minutes, another group of tourists posed in the zebra crossing.

Jan 6, 2012
Post comments count 0
Post likes count 1

Why did HeapFree fail with ERROR_POSSIBLE_DEADLOCK?

Raymond Chen

A customer reported that they were receiving some assertion failures because the function was failing with what they believed to be a valid heap block, and the function reported that the reason for failure was . What's going on? One of my colleagues asked the psychic question, "Is the process exiting?" "Why yes, in fact it is. How did you know?" Recall how processes exit. One of the first things that happens is that all the other threads in the process are forcible terminated, which has as a consequence that any synchronization resources owned by those threads are now orphaned. And in this case, the synchro...

Jan 5, 2012
Post comments count 0
Post likes count 1

A joke for mathematicians: On the Weyl schism

Raymond Chen

In one of my mathematics classes, the professor noted (and freely admitted that the joke was not original with him), "There are essentially two groups of mathematicians: Those that have read Weyl and those that have not. And once you enter the first group, you will never be understood by anyone in the second group." I guess it's only funny to mathematicians.

Jan 5, 2012
Post comments count 0
Post likes count 1

When DLL_PROCESS_DETACH tells you that the process is exiting, your best bet is just to return without doing anything

Raymond Chen

When the function receives a reason code of , the increasingly-inaccurately-named parameter to is used to indicate whether the process is exiting. And if the process is exiting, then you should just return without doing anything. No, really. Don't worry about freeing memory; it will all go away when the process address space is destroyed. Don't worry about closing handles; handles are closed automatically when the process handle table is destroyed. Don't try to call into other DLLs, because those other DLLs may already have received their notifications, in which case they may behave erratically in the same...