The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
Why doesn't TryEnterCriticalSection try harder?
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
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...
Why can't I get my regular expression pattern to match words that begin with %?
A customer asked for help writing a regular expression that, in the customer's words, matched the string when it appeared as a standalone word. One of the things that people often forget to do when asking a question is to describe the things that they tried and what the results were. This is important information to include, because it saves the people who try to answer the question from wasting their time repeating the things that you already tried. That last entry was just to make sure that the test app was working, a valuable step when chasing a problem: First, make sure the problem is where you think it...
Email tip: When asking for help with a problem, also mention what you've already tried
When you ask a question, you should also mention what steps you've already taken when attempting to solve it on your own. First of all, it saves the people who decide to help you with your problem from exploring lines of investigation which you've already tried (and which you know don't work). "I tried setting the timeout to 60 seconds before issuing the call, but it still failed with the error ." Second, it cuts down on noise on the discussion list. — Try setting the timeout to a higher value. "I already tried that; it didn't work." Third, it demonstrates that you cared enough about the problem to try...
Email tip: When you say that something didn't work, you have to say how it didn't work
I illustrate this point with an imaginary conversation, inspired by actual ones I've seen (and, occasionally, been a frustrated party to). From: X I want to do ABC, but I don't have a DEF. Anybody know of a workaround? Somebody has an idea: From: Y Try mounting this ISO file into a virtual machine and trying the ABC from there. Unfortunately, it didn't work: From: X I tried that, but it didn't work. Any other ideas? When somebody suggests a troubleshooting step or a workaround, but when you try it and it doesn't work, you need to say how it didn't work. The person who made the suggestion had...
The difference between your job and your hobby
There was an internal discussion about what Microsoft employees should be doing that do not directly relate to their job responsibilities, such as what text editor programmers should be using to write and edit code. Should anybody who uses a programming editor other than Visual Studio be branded a traitor? How about somebody who prefers a smartphone made by a certain Cupertino company? (And for some reason, this discussion took place on the Microsoft bloggers mailing list, because many people consider it a mailing list whose members are bloggers, as opposed to a mailing list for discussing blogging. I happen to...
Why does the wireless connection dialog ask for your password twice?
Martin wonders why the wireless networking dialog asks you to type your password twice when connecting to an existing network. Yeah, that bothers me too, and I don't know why either. But while we're on the topic of wireless networking, I thought I'd share a little program that is just as useless as my answer above. (If other people get to hijack the topic, then I want to also.) Back in the early days of Windows XP, I found that my wireless networking adapter would constantly disconnect and reconnect. I never figured out why, but I did have a theory. (Theory: The wireless zero configuration service sa...
The mysterious stock bitmap: There's no way to summon it, but it shows up in various places
A number of stock GDI objects are made available by the function, but one stock GDI object that is mysteriously missing is the stock bitmap. You can't summon the stock bitmap, but it manages to show up in various places, some of them perhaps unexpected. The stock bitmap is a monochrome 1×1 bitmap which GDI uses in various places where it has to produce a even though there really isn't any bitmap worth speaking of. In other words, it's used when GDI has to return something but would rather return nothing. When you create a memory DC, the current bitmap selected into it is the stock bitmap. When yo...
Why are there two values for NoDriveTypeAutoRun which disable Autoplay on drives of unknown type?
The Windows 2000 Resource Kit described the policy as consisting of a bitfield whose values are as follows: Hey, wait, two of the entries are the same. What's the difference between 0x1 (Disables Autoplay on drives of unknown type) and 0x80 (Disables Autoplay on drives of unknown type)? The values in the bitfield correspond to return values of the function: The value 0x1 corresponds to bit zero, which means that the function could not tell what type of drive it is. On the other hand, the value 0x80 does not correspond to any known return value of . It's reserved for future use. My guess as to ho...