The Old New Thing

The ways people mess up IUnknown::QueryInterface, episode 4

One of the rules for is so obvious that nobody even bothers to state it explicitly as a rule: "If somebody asks you for an interface, and you return , then the pointer you return must point to the interface the caller requested." (This feels like the software version of dumb warning labels.) During compatibility testing for Windows ...

Menu item states are not reliable until they are shown because they aren't needed until then

A question arrived from a customer (with the rather unhelpful subject line Question for Microsoft) wondering why, when they call and then ask for the states of the various menu items like , the menu item states don't reflect reality. The menu item states don't synchronize with reality until the user actually opens the system menu. There is ...

Why doesn't b match word boundaries correctly?

A colleague of mine was having trouble getting the metacharacter in a regular expression to work. Of course, when somebody asks a question like that, you first have to establish what their definition of "work" is. Fortunately, he provided some examples: "The last two entries are just sanity checks to make sure I didn't make some stupid ...

Simulating input via WM_CHAR messages may fake out the recipient but it won't fake out the input system

We saw some time ago that you can't simulate keyboard input with . You may get away with it, depending on how the application you're trying to fake out processes input, but since you're just faking data, the application may discover that it's all a ruse when they try to access information that you didn't fake out, say by calling and ...

You don't need to ask me a question the compiler can answer more accurately

A customer reported having problems developing the correct p/invoke signature for the structure. "The code works on 32-bit machines, but on 64-bit machines, the call to returns ." The sample code included the lines My response was simply, "I bet you are passing the wrong structure size. Note that on 64-bit Windows, the alignment of the...