Showing results for April 2011 - The Old New Thing

Apr 29, 2011
0
0

Not quite understanding why you wash your hands before playing the piano

Raymond Chen
Raymond Chen

My niece wanted to play my piano, and I asked her to wash her hands. She said, "I don't need that, I have Magic Soap," and she produced a bottle of hand sanitizer. Um, the purpose of washing your hands isn't so the piano doesn't get sick. My piano-instructor cousin-in-law tells me that her young students often say, "My hands are not dirty. They ...

Non-Computer
Apr 29, 2011
0
0

Why is there a RestoreLastError function that does the same thing as SetLastError?

Raymond Chen
Raymond Chen

Matt Pietrek noticed that and do exactly the same thing and wondered why there's a separate function for it. It's to assist in debugging and diagnostics. Say you're debugging a problem and when you call you get . It would really help a lot if you could figure out who set the error code to . If you set a breakpoint on , you find that people...

Code
Apr 28, 2011
0
0

Microspeak: Hipo

Raymond Chen
Raymond Chen

A friend of mind was asked out of the blue, "What does hypo mean?" She started to flash back to high school English class and Greek word roots. "I've started to hear it everywhere. Like Everyone in that meeting is a hypo or We need to reach out to hypos." My friend realized that she had mis-heard the question. It was not about the Greek root hyp...

Non-ComputerMicrospeak
Apr 27, 2011
0
0

How do I pin a program directly to the Start menu rather than a shortcut?

Raymond Chen
Raymond Chen

Anonymous bemoans the fact that pinning programs to the Start menu (in Windows XP) actually pins the shortcut rather than the program itself. This means that if you right-click on a shortcut to pin it, then delete the shortcut, the pinned item stops working. How do you pin the program directly? You pin the program directly by right-clicking ...

Tips/Support
Apr 26, 2011
0
0

No, you can't ask whether your notification icon is visible or not

Raymond Chen
Raymond Chen

A customer asked what started out as a simple question, but by now you know that this sort of simple question only raises new questions: Is there a way that we can detect that the user has hidden our notification icon? No, there is no way to ask whether your notification icon is hidden or visible. Users decide which icons they want to see, and y...

Code
Apr 25, 2011
0
0

There's only so much you can do to stop running code from simulating UI actions

Raymond Chen
Raymond Chen

Commenter KiwiBlue asks whether Captcha-style tests were considered to prevent unsigned drivers from programmatically clicking the 'Install anyway' button. I'm sure somebody considered it, but Captcha has its own problems. "Type the (distorted) letters below"-type Captcha cannot be used by people with visual impairments, people who are dyslexic,...

Other
Apr 22, 2011
0
0

Even if you have a lock, you can borrow some lock-free techniques

Raymond Chen
Raymond Chen

Even if you prefer to use a lock (after all, they are much easier to program), you can borrow some lock-free techniques. For example, consider this: There are some concerns here. First of all, there's the lock hierarchy issue: If reticulating a spline takes the geometry lock, that may violate our lock hierarchy. If the lock is a hot lock, yo...

Code
Apr 21, 2011
0
0

The performance improvements of a lock-free algorithm is often not in the locking

Raymond Chen
Raymond Chen

GWO wonders what the conditions are under which the lock-free version significantly outpeforms a simple critical section. Remember that switching to a lock-free algorithm should be guided by performance measurements. Switching from a simple algorithm to a complex one shouldn't be done unless you know that the simple algorithm is having trouble....

Code
Apr 20, 2011
0
0

Corrections to Patterns for using the InitOnce functions

Raymond Chen
Raymond Chen

Adam Rosenfield pointed out that it is not possible to fail an asynchronous initialization; if you pass when completing an asynchronous initialization, the function fails with . (Serves me right for writing an article the night before it goes up.) A more correct version is therefore In other words, the pattern is as follows: While I'm her...

Code