The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Jan 11, 2010
Post comments count 0
Post likes count 0

Pros and cons of using a four-year-old as your language instructor

Raymond Chen

I have a niece who is a native speaker of Chinese. Playing with her is a free language lesson, and there are advantages and disadvantages. One advantage is that you will learn all the basic words, and you won't run the risk that your instructor will accidentally use some advanced vocabulary that will throw you off. (You also learn some words that are very important to young children like butt and fart.) Fortunately, my niece's pronunciation is very good, so it's not like I'm accidentally learning to speak with a lisp or a childhood speech impediment. One disadvantage is that you're learning kiddie-talk: My nie...

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

Why aren't compatibility workarounds disabled when a debugger is attached?

Raymond Chen

Ken Hagan wonders why compatibility workarounds aren't simply disabled when a debugger is attached. As I noted earlier, many compatibility workarounds are actually quicker than the code that detects whether the workaround would be needed. Now suppose you find a compatibility problem with some applications that expect the function to return exactly or . You then change the function to something like this: Now, we add code to enable the compatibility workaround only if the application is on the list of known applications which need this workaround: What was a simple flag test now includes a check to ...

Jan 8, 2010
Post comments count 0
Post likes count 1

What is the hSection parameter to CreateDIBSection for?

Raymond Chen

The function creates a special type of bitmap known as a DIB section. We've worked with these guys before: The feature of DIB sections that is by far the most interesting is that the raw pixels in the bitmap are mapped into your process space as if they were normal memory, which you can read from and write to directly. But what is the deal with that funky parameter? Although the parameter receives "a pointer to the location of the DIB bit values," the documentation also says that if you pass , then "an application cannot later obtain a handle to this memory." That second part makes no sense. Why would I wan...

Jan 7, 2010
Post comments count 0
Post likes count 0

Learning how to cheat at Candy Land

Raymond Chen

My young niece received the game Candy Land and wants to play it several times a day. Naturally, I am frequently drafted as an opponent. I discovered that my niece cheats rampantly. Sometimes, she will advance three green squares instead of two. Or if a yellow card will take her to a licorice square (lose a turn), she will ignore it and go to the yellow square after that. But the best cheating takes place when she draws a pink location card which sends her backward. My niece is always careful to draw the card and turn it so only she can see what it is. If the card is an unfavorable one, she will hide it under ...

Jan 7, 2010
Post comments count 0
Post likes count 1

How to change the debugger attached to a process

Raymond Chen

Suppose your application crashes and debugger X is automatically connected because that's how the system happened to be configured. But you would prefer to use debugger Y. After installing debugger Y, how do you switch the debugger from X to Y? If you try to connect debugger Y to the process, you get the error code , because only one debugger can be connected to a process at a time. But if you disconnect the old debugger, the application will disappear with it. How do you escape from this Catch-22? Here's what you do. This trick works because the non-invasive mode of debugging do...

Jan 6, 2010
Post comments count 0
Post likes count 0

The wisdom of seventh graders: Success

Raymond Chen

Seventh grade students (ages 12 to 13, roughly) were asked to write an essay on what success is and how you know when you've achieved it. The assignment was given under standardized test conditions: 90 minutes with nothing but pencil and paper, with an additional hour available upon request. (In practice, few students ask for the extra hour.) Remember, these are only the funny sentences/excerpts. Do not assume that all students write like this. On the nature of success Recognizing success Steps which do not lead to success The fleeting nature of success The recipe for success Personal stories of succ...

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

Can you get rotating an array to run faster than O(n²)?

Raymond Chen

Some follow-up remarks to my old posting on rotating a two-dimensional array: Some people noticed that the article I linked to purporting to rotate the array actually transposes it. I was wondering how many people would pick up on that. I was surprised that people confused rotating an array (or matrix) with creating a rotation matrix. They are unrelated operations; the only thing they have in common are the letters r-o-t-a-t-i. A matrix is a representation of a linear transformation, and a rotation matrix is a linear transformation which rotates vectors. In other words, applying the rotation matrix to a vec...

Jan 5, 2010
Post comments count 0
Post likes count 0

Thanks for coming together to enjoy the holiday together, now get off my lawn

Raymond Chen

Due to a confluence of circumstances involving parents on an overseas vacation and other older relatives choosing not to attend (probably related to parents being out of town), I ended up being the oldest person at the extended family holiday dinner table. This was a first for me, and I resisted the urge to shout "Get off my lawn!" to the assembled masses or to bore younger relatives with rambling pointless stories from my youth. I guess this is the converse to a friend of mine who presided over a holiday family gathering at his house some years ago, and who realized that if seating at the dinner table were don...

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

Microspeak: Engagement

Raymond Chen

Meetings are so passé. You no longer have a meeting with a customer; you have an engagement: I have a customer engagement tomorrow and they have a question surrounding Feature X. Note that this use of the phrase customer engagement is different from the process known as customer engagement. The process is an ongoing interaction, a long-term activity to build customer loyalty. The author of the above sentence is not using it in the process sense (because you don't have "a" customer engagement; rather, a meeting is one component of the overall process of customer engagement). Nope, the author is jus...