What did Windows 3.1 do when you hit Ctrl+Alt+Del?
This is the end of Ctrl+Alt+Del week, a week that sort of happened around me and I had to catch up with. The Windows 3.1 virtual machine manager had a clever solution for avoiding deadlocks: There was...
View ArticleEnumerating all the ways of making change
Today's Little Program enumerates all the ways of making change for a particular amount given a set of available denominations. The algorithm is straightforward. To make change for a specific amount...
View ArticleMicrospeak: spend
Remember, Microspeak is not merely for jargon exclusive to Microsoft, but it's jargon you need to know. We don't encounter the term spend much in the engineering side of the company, but it's in...
View ArticlePoor man's comments: Inserting text that has no effect into a configuration file
Consider a program which has a configuration file, but the configuration file format does not have provisions for comments. Maybe the program has a "list of authorized users", where each line takes...
View ArticleThe citizenship test is pass/fail; there's no blue ribbon for acing it
The civics portion of the United States citizenship test is an oral exam wherein you must correctly answer six out of ten questions. One of my friends studiously prepared for his examination, going so...
View ArticleThe stream pointer position in IDataObject::GetData and...
An oft-overlooked detail of the IDataObject::GetData and IDataObject::GetDataHere methods is the position of the stream pointer when the result is a stream. These rules are buried in the...
View ArticleI marked my parameter as [optional], so why do I get an RPC error when I pass...
Consider the following interface declaration in an IDL file: // Code in italics is wrong interface IFoo : IUnknown { HRESULT Cancel([in, optional, string] LPCWSTR pszReason); }; The idea here is that...
View ArticleReceiving a notification any time the selection changes in an Explorer window
Today's Little Program merely prints a message whenever the user changes the selection on the desktop. I chose the desktop for expediency, since it saves me the trouble of coming up with a way for the...
View ArticleThe grand ambition of giving your project the code name Highlander
Code name reuse is common at Microsoft, and there have been several projects at code-named Highlander, the movie with the tag line There can be only one. (Which makes the whole thing kind of ironic.)...
View ArticleWhat is the story of the mysterious DS_RECURSE dialog style?
There are a few references to the DS_RECURSE dialog style scattered throughout MSDN, and they are all of the form "Don't use it." But if you look in your copy of winuser.h, there is no sign of...
View ArticleIf a process crashes while holding a mutex, why is its ownership magically...
A customer was observing strange mutex ownership behavior. They had two processes that used a mutex to coordinate access to some shared resource. When the first process crashed while owning the mutex,...
View ArticleMarshaling won't get in your way if it isn't needed
I left an exercise at the end of last week's article: "Why is the RPC_X_NULL_REF_POINTER error raised only sometimes?" COM subscribes to the principle that if no marshaling is needed, then an...
View ArticleSimulating media controller buttons like Play and Pause
Today's Little Program simulates pressing the Play/Pause button on your fancy keyboard. This might be useful if you want to write a program that converts some other input (say, gesture detection) into...
View ArticleWhy does misdetected Unicode text tend to show up as Chinese characters?
If you take an ASCII string and cast it to Unicode,¹ the results are usually nonsense Chinese. Why does ASCII→Unicode mojibake result in Chinese? Why not Hebrew or French? The Latin alphabet in ASCII...
View ArticleYou can name your car, and you can name your kernel objects, but there is a...
A customer reported that the WaitForSingleObject appeared to be unreliable. We have two threads, one that waits on an event and the other that signals the event. But we found that sometimes,...
View ArticleIn the red corner, EXCEPTION_INT_DIVIDE_BY_ZERO and...
The exception code EXCEPTION_INT_DIVIDE_BY_ZERO (and its doppelgänger STATUS_INTEGER_DIVIDE_BY_ZERO) is raised, naturally enough, when the denominator of an integer division is zero. The x86 and x64...
View ArticleWhy is 0x00400000 the default base address for an executable?
The default base address for a DLL is 0x10000000, but the default base address for an EXE is 0x00400000. Why that particular value for EXEs? What's so special about 4 megabytes It has to do with the...
View ArticleEnumerating cyclical decompositions with Stirling numbers
This whole enumeration nightmare-miniseries started off with Stirling numbers of the second kind. But what about Stirling numbers of the first kind? Those things ain't gonna enumerate themselves! The...
View ArticleMicrospeak: All-up
Here are some citations. Let's see if we can figure out what it means. I think a presentation of these results would be a fun boost for the team. Is this something we should handle in a bunch of...
View ArticleStandard handles are really meant for single-threaded programs
When I discussed the conventions for managing standard handles, Sven2 noted that I implied that you need to call SetStdHandle with a new handle if you close the current handle and asked "Wouldn't it...
View Article