The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Feb 3, 2011
Post comments count 0
Post likes count 1

Ready… cancel… wait for it! (part 2)

Raymond Chen

A customer had a question about I/O cancellation. They have a pending call with a completion procedure. They then cancel the I/O with and wait for the completion by passing as the parameter to . Assuming both return success, can I assume that my completion procedure will not be called after GetOverlappedResult returns? It appears that GetOverlappedResult waits non-alertably for the I/O to complete, so I'm assuming it just eats the APC if there was one. But if an APC had been posted just before I called CancelIoEx, will it also cancel that APC? does not magically revoke completion callbacks. Why should it?...

Feb 2, 2011
Post comments count 0
Post likes count 1

Ready… cancel… wait for it! (part 1)

Raymond Chen

One of the cardinal rules of the structure is the structure must remain valid until the I/O completes. The reason is that the structure is manipulated by address rather than by value. The word complete here has a specific technical meaning. It doesn't mean "must remain valid until you are no longer interested in the result of the I/O." It means that the structure must remain valid until the I/O subsystem has signaled that the I/O operation is finally over, that there is nothing left to do, it has passed on: You have an ex-I/O operation. Note that an I/O operation can complete successfully, or it can comp...

Feb 1, 2011
Post comments count 0
Post likes count 1

There is no longer any pleasure in reading the annual Microsoft injury reports

Raymond Chen

Microsoft is required by law to file reports on employees who have sustained injuries on the job. They are also required to post the reports in a location where employees can see them. These reports come out every year on February 1. Back in the old days, these reports were filled out by hand, and reading them was oddly amusing for the details. My favorite from the mid 1990's was a report on an employee who was injured on the job, and the description was simply pencil lead embedded in hand. Sadly, the reports are now computerized, and there isn't a place to describe the nature of each injury. It's just a b...

Jan 31, 2011
Post comments count 0
Post likes count 1

Solutions that require a time machine: Making applications which require compatibility behaviors crash so the developers will fix their bug before they ship

Raymond Chen

A while ago, I mentioned that there are many applications that rely on messages being delivered even if there is nothing to paint because they put business logic inside their handler. As a result, Windows sends them dummy messages. Jerry Pisk opines, Thanks to the Windows team going out of their way not to break poorly written applications developers once again have no incentive to clean up their act and actually write working applications. If an application requires a dummy WM_PAINT not to crash it should be made to crash as soon as possible so the developers go in and fix it before releasing their "code"...

Jan 28, 2011
Post comments count 0
Post likes count 2

Some remarks on VirtualAlloc and MEM_LARGE_PAGES

Raymond Chen

Large pages are a special feature for dedicated server processes.

Jan 27, 2011
Post comments count 0
Post likes count 1

How do you obtain the icon for a shortcut without the shortcut overlay?

Raymond Chen

The easy one-stop-shopping way to get the icon for a file is to use the function with the flag. One quirk of the function is that if you pass the path to a shortcut file, it will always place the shortcut overlay on the icon, regardless of whether you passed the flag. (Exercise: What is so special about the shortcut overlay that makes it exempt from the powers of the flag? The information you need is on the MSDN page for , though you'll have to apply some logic to the sitaution.) I'm using SHGet­File­Info to get the icon of a file to display in my application. When the file is a shortcut, rather t...

Jan 26, 2011
Post comments count 0
Post likes count 1

Microspeak: Leverage

Raymond Chen

At Microsoft, leverage is not a term of physics whereby a force can be magnified by the application of mechanical advantage. It is also not a term of finance whereby the power of a small amount of money can be magnified by the assumption of debt. In fact, at Microsoft, the word leverage isn't even a noun. It is a verb: to leverage, leverages, leveraging, leveraged, has leveraged. Oh, and it has nothing to do with magnification. Here are some citations: How do I leverage a SiteMap? Allow advertising partners to leverage this resource for providing targeted advertising links. Leverage existing design to power...

Jan 25, 2011
Post comments count 0
Post likes count 1

Why does the name of my TEMP directory keep changing?

Raymond Chen

A customer liaison contacted the shell team with the following request: Subject: Support case: 069314718055994 On two of my customer's machines, he's finding that if he opens %TEMP% from the Start menu, it opens C:\Users\username\AppData\Local\Temp\1, C:\Users\username\AppData\Local\Temp\2, and so on. Each time the user logs off and back on, the number increments. The number resets after each reboot. Why are we seeing these folders being created under Temp? This does not appear to be the default behavior. What would cause the operating system to create these folders? The customer rebuilt one of the affected m...

Jan 24, 2011
Post comments count 0
Post likes count 1

There's a default implementation for WM_SETREDRAW, but you might be able to do better

Raymond Chen

If your window doesn't have a handler for the message, then will give you a default implementation which suppresses messages for your window when redraw is disabled, and re-enables (and triggers a full repaint) when redraw is re-enabled. (This is internally accomplished by making the window pseudo-invisible, but that's an implementation detail you shouldn't be concerned with.) Although the default implementation works fine for simple controls, more complex controls can do better, and in fact they should do better, because that's sort of the point of . The intended use for disabling redraw on a window is in...