The Old New Thing

How can I extend the deadline for responding to the PBT_APMSUSPEND message?

A customer observed that starting in Windows Vista, the deadline for responding to the message was reduced from twenty seconds to two seconds. Their program needs more than two seconds to prepare for a suspend and they wanted to know how they could extend the deadline. The program communicates with a device, and if they don't properly ...

It is not unreasonable to expect uninitialized garbage to change at any time, you don't need to ask for an explanation

A customer admitted that they had a bug in their code: One bug in the above code is in the final parameter passed to : It's supposed to be the count in bytes, but the calculation appends only one byte for the terminating null instead of a full . In other words, it should be For concreteness, let's say the original string was five s in ...

How can I tell whether a COM pointer to a remote object is still valid?

A customer asked the rather suspicious question, "How do I check whether a pointer is valid in another process?" This question should make your head boggle with bewilderment. First of all, we've moved beyond to . Second of all, what the heck are you doing with a pointer in another process? You can't do anything with it! After some back-and...

How do I generate a unique 32-bit value for a time zone?

Public Service Announcement: Daylight Saving Time ends in most parts of the United States this weekend. Other parts of the world may change on a different day from the United States. A customer asked the following question: Given two structures, I would like to compute a for each that I can then compare to determine whether they ...

Why isn't my transparent static control transparent?

A customer reported that their application uses transparent static controls positioned over a bitmap image control, but even though they set the Transparent property on the static control, the static control isn't transparent. The customer was kind enough to provide clear steps to illustrate the problem: Open Visual Studio 2005 or 2008. ...

How can I get notified when some other window is destroyed?

A customer wanted to know whether there was a method (other than polling) to monitor another window and find out when it gets destroyed. The goal was to automate some operation, and one of the steps was to wait until some program closed its XYZ window before moving on to the next step. Finding the XYZ window could be done with a , but since ...

The PSN_SETACTIVE notification is sent each time your wizard page is activated

A customer had received a number of crashes via Windows Error Reporting and believed that they had found a bug in the tree view common control. In our UI, we have a tree view with checkboxes. The tree view displays a fixed item at the top, followed by a variable number of dynamic items. When the user clicks Next, we look at the tree view ...