Can CoCreateGuid ever return GUID_NULL?
A customer asked whether the CoCreateGuid function can ever return GUID_NULL. Their code uses GUID_NULL for special purposes, and it would be bad if that was ever returned as the GUID for an object....
View ArticleFunctions that return GDI regions rarely actually return regions
For reasons I don't quite understand, the only functions in GDI and USER which create GDI regions are the functions with Create in their name, like CreateRectRgn or CreatePolygonRgn. All the other...
View ArticleThe dangers of buffering up posted messages and then reposting them later
A customer wanted to check that their idea for solving a re-entrancy problem doesn't have any hidden gotchas. We have a window which processes incoming work. One of our work items enters a modal loop,...
View ArticleA puzzle involving dynamic programming, or maybe it doesn't
Here's a programming challenge: Evaluate the following recurrence relation efficiently for a given array [x0, …, xn−1] and integer k. f ([x0, x1], k) = (x0 + x1) / 2 for all k, n = 2. f ([x0, …,...
View ArticleBuggy milk cartons, beeping computers, and other silliness
Some time ago, there was a performance-related bug that went something like this: mm/dd/yy Created by bob The attached file contains a dataset that takes a very long time to process. The engineer who...
View ArticleIt rather involved being on the other side of this airtight hatchway: Invalid...
A few years after I posted this story, the security team received something very similar. If have found that if you call the XYZ function (whose last parameter is supposed to be a pointer to a DWORD)...
View ArticleWhy does the access violation error message put the operation in quotation...
When an application crashes with an access violation, the error message says something like The instruction at "XX" referenced memory at "YY". The memory could not be "read". Why is the operation in...
View ArticleIt's bad enough for a guest to demolish the host's house; demolishing an...
"How do I destroy a window that belongs to another process?" The DestroyWindow function will not destroy windows that belong to another thread, much less another process. The best you can do is post...
View ArticleUsing WM_SETREDRAW to speed up adding a lot of elements to a control
Today's Little Program shows one way you can implement a better version of WM_SETREDRAW. Our first version doesn't use WM_SETREDRAW at all. Start with the scratch program and make the following...
View ArticleWhy is Rundll32 called Rundll32 and not just Rundll?
There is an oft-abused program named rundll32.exe. Why does its name end in 32? Why not just call it rundll.exe? (I will for the moment ignore the rude behavior of calling people stupid under the...
View ArticleWhat happens to my COM server-side object when clients die unexpectedly?
Suppose you have a COM server object that runs out-of-process. A client connects to the COM server and creates an object. And then the client crashes. What happens to the server object? It will get...
View ArticleWhy does PrintWindow hate CS_PARENTDC? redux
Why does PrintWindow hate CS_PARENTDC? Because everybody hates CS_PARENTDC! Commenter kero claims that it's "easy to fix" the problem with PrintWindow and CS_PARENTDC. You just remove the...
View ArticleWindows is not a Microsoft Visual C/C++ Run-Time delivery channel
There's a DLL in the system directory called MSVCRT.DLL, and from its name, you might think that it is the Microsoft Visual C/C++ Run-Time library. That is a perfectly reasonable guess. But it would...
View ArticleEnumerating subsets with binomial coefficients
Inspired by the Little Program which enumerates set partitions, I decided to do the binomial coefficients this week. In other words, today's Little Program generates all subsets of size k from a set...
View ArticleThe geeky thrill of discovering that two things are really the same thing,...
Today's post about binomial coefficients was intended to be a warm-up for Catalan numbers, but it turns out Eric Lippert already covered them, first in the context of binary trees, then in the context...
View ArticleMicrospeak: bar check
A bar check sounds like the sort of thing you receive at the end of a long evening of drinking, but that's not what a bar check is. Among the things that happen at ship room meetings is reviewing each...
View ArticleThe gradual erosion of the car trip experience, part 2
When I learned that my nieces were heading out on a road trip, I asked, "Are you going to sing songs?" My eldest niece looked at me as if I were from Mars, then replied, "No, we bring electronics."
View ArticleThere is no complete list of all notifications balloon tips in Windows
A customer wanted a complete list of all notifications balloon tips in Windows. There is no such list. Each component is responsible for its own balloon tips and is not required to submit their list...
View ArticleHow can I get the Windows 8 touch keyboard to display autocomplete...
A customer observed that if you use the Windows 8 Bing app with the touch keyboard, the top of the touch keyboard includes autocomplete suggestions for quick access. They wanted to know how to enable...
View ArticleHow do I set a breakpoint on a function whose name contains spaces or other...
If you use one of the command line debuggers based on the Debugger Engine, you can set a breakpoint on a function whose name contains spaces or other special characters by quoting the symbol name. The...
View Article