The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Welcome to Belém, the scam artist capital of Lisbon
May 3, 2010
Post comments count 0
Post likes count 0

Welcome to Belém, the scam artist capital of Lisbon

Raymond Chen
Raymond Chen

It has been quite a while since I was in Lisbon for a conference, but I still have a bunch of tiny travel stories. They may not be timely, but they're just stories. Lisbon is a wonderful city, and unlike Madrid, it doesn't have the feeling that it's overrun with tourists. It may very well be overrun with tourists, but at least it doesn't scream it at you. Well, until you get to the Belém neighborhood, which is where all the big monuments and famous historical buildings are. The sense begins to grow at the Padrão dos Descobrimentos (Monument to the Discoveries), and by the time you reach the To...

How do I accept files to be opened via IDropTarget instead of on the command line?
May 3, 2010
Post comments count 0
Post likes count 0

How do I accept files to be opened via IDropTarget instead of on the command line?

Raymond Chen
Raymond Chen

Commenter Yaron wants to know how to use the new IDropTarget mechanism for receiving a list of files to open. (Also asked by Anthony Wieser as a comment to an article.) The MSDN documentation on Verbs and File Assocations mentions that DDE has been deprecated as a way of launching documents and that you should use the DropTarget method instead. But what is the DropTarget method? (Note that the word method here is in the sense of technique and not in the C++ sense of function that belongs to a class.) The documentation in MSDN tells you what to do, but it does so very tersely. It says to create a key under ...

Welcome to Taiwan's premier English-only nightclub
Apr 30, 2010
Post comments count 0
Post likes count 0

Welcome to Taiwan's premier English-only nightclub

Raymond Chen
Raymond Chen

One of my friends is fluent in both Mandarin and English. When she lived in Taiwan, she paid a visit to a nightclub whose gimmick was that you had to speak English. The target audience was not foreigners but rather native Taiwanese who learned English as a second language. My friend didn't have any problems with this rule, but many of the guests appeared to be struggling to conform. My friend paid a visit to the ladies' room, and there she overheard a conversation between two other guests. (They were speaking in Mandarin. Apparently, the rules aren't enforced in the bathroom.) "There's this cute guy out on the ...

If it's not yours, then don't mess with it without permission from the owner
Apr 30, 2010
Post comments count 0
Post likes count 0

If it's not yours, then don't mess with it without permission from the owner

Raymond Chen
Raymond Chen

It's surprising how many principles of real life also apply to computer programming. For example, one of the rules of thumb for real life is that is that if something doesn't belong to you, then you shouldn't mess with it unless you have permission from the owner. If you want to ride Jimmy's bike, then you need to have Jimmy's permission. Even if Jimmy leaves his bicycle unlocked in his driveway, that doesn't mean that it's available for anyone to take or borrow. In computer programming, the code that creates an object (or on whose behalf the object is created) controls what is done with the object, and if you'r...

A short puzzle about heap expansion
Apr 29, 2010
Post comments count 0
Post likes count 0

A short puzzle about heap expansion

Raymond Chen
Raymond Chen

At the 2008 PDC, somebody stopped by the Ask the Experts table with a question about the heap manager. I don't understand why the heap manager is allocating a new segment. I allocated a bunch of small blocks, then freed nearly all of them. And then when my program makes a large allocation, it allocates a new segment instead of reusing the memory I had just freed. Under the classical model of the heap, the heap manager allocates a large chunk of memory from lower-level operating system services, and then when requests for memory come in from the application, it carves blocks of memory from the big chunk a...

What happens to the contents of a memory-mapped file when a process is terminated abnormally?
Apr 28, 2010
Post comments count 0
Post likes count 0

What happens to the contents of a memory-mapped file when a process is terminated abnormally?

Raymond Chen
Raymond Chen

The same thing that happens when the handle is leaked.

He bought the whole seat, but we only needed the edge
Apr 27, 2010
Post comments count 0
Post likes count 0

He bought the whole seat, but we only needed the edge

Raymond Chen
Raymond Chen

After the Windows 95 project was released to manufacturing, but before the launch event itself, the team finally had a chance to relax and unwind after many years of hard work. The project manager decided to have a morale event to get everyone together to do something fun. A typical morale event might be going to see a baseball game, renting out a movie theater to watch the latest action flick, or something as simple as a picnic or a softball game. But this time, the project manager decided to do something different, something wild, something crazy, something everybody would talk about for days: He bought ...

Why doesn't TryEnterCriticalSection try harder?
Apr 26, 2010
Post comments count 0
Post likes count 0

Why doesn't TryEnterCriticalSection try harder?

Raymond Chen
Raymond Chen

Bart wants to know why the gives up if the critical section is busy instead of trying the number of times specified by the critical section spin count. Actually, there was another condition on the proposed new behavior: "but does not release its timeslice to the OS if it fails to get it while spinning." This second condition is a non-starter because you can't prevent the operating system from taking your timeslice away from you. The best you can do is detect that you lost your previous timeslice when you receive the next one. And even that is expensive: You have to keep watching the CPU cycle counter, and if...

Our legal department suggests you skip our salad dressing and just eat an avocado
Apr 23, 2010
Post comments count 0
Post likes count 0

Our legal department suggests you skip our salad dressing and just eat an avocado

Raymond Chen
Raymond Chen

I saw a bottle of salad dressing with very strange fine print. The picture on the bottle is of half an avocado. But the fine print on the bottle reads "Does not contain avocados." Okay, so the picture on the bottle isn't a picture of the product. This is strange but not entirely unheard of. After all, a box of Girl Scout cookies has pictures of Girl Scouts, not cookies. The thing that struck me was the second half of the fine print. It reads "Serving suggestion." Huh? Apparently, the suggested way of enjoying their salad dressing is to eat half an avocado with no salad dressing on it. Pre-emptive snarky co...