The Old New Thing

If you protect a write with a critical section, you may also want to protect the read

It is common to have a critical section which protects against concurrent writes to a variable or collection of variables. But if you protect a write with a critical section, you may also want to protect the read, because the read might race against the write. Adam Rosenfield shared his experience with this issue in a comment from a few ...
Comments are closed.0 0
Code

Things I've written that have amused other people, Episode 8

In a technical discussion, I opened a reply with Bob's paper which I haven't yet read points out that... Some people wrote to me to say that the've added this quote to their file in the hopes of being able to use it themselves someday. For those who are curious, I found the technical discussion in question. It had to do with whether the...

Why is CLIPFORMAT defined to be a WORD rather than a UINT?

Commenter Ivo wants to know if the Register­Clipboard­Format function returns a UINT, why is the CLIP­FORMAT data type defined to be a WORD? Since a WORD is smaller than a UINT, you have to stick in a cast every time you assign the result of Register­Clipboard­Format to a CLIP­FORMAT. Rewind to 16-bit Windows. Back in...

How to insert a large number of items into a treeview efficiently

Just a quick tip today. If you need to insert a large number of items into a treeview, like tens of thousands, then it's much more efficient to insert them "backwards". (I'm ignoring for now the usability question of having a treeview that large in the first place.) In other words, instead of do it this way: Why is backwards-insertion ...
Comments are closed.0 0
Code

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 PBT_APMSUSPEND 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 ...
Comments are closed.0 0
Code

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 Reg­Set­Value­Ex: It's supposed to be the count in bytes, but the calculation appends only one byte for the terminating null instead of a full TCHAR. In other words, it should be For concreteness, let's say the...
Comments are closed.0 0
Code

The Control Panel search results understand common misspellings, too

Here's a little trick. Open your Start menu and type scrensaver into the search box. That's right, spell it with only one e. Hey, it still found the Control Panel options for managing your screen saver. If you enable Improve my search results by using online Help in Windows Help and Support, this sends your search query to a back-end server ...

Why not use animated GIFs as a lightweight alternative to AVIs in the animation common control?

Commenter Vilx- wondered why animated GIFs weren't used as the animation format for the shell animation common control. After all, "they are even more lightweight than AVIs." Animated GIFs are certainly more lightweight than general AVIs, since AVI is just a container format, so decoding a general AVI means decoding any encoding format ...

Why does Internet Explorer not call DLL_PROCESS_DETACH on my DLL when I call ExitProcess?

A customer asked a question, but as is often the case, the question was much more telling than the answer. We have an Internet Explorer plug-in which calls Exit­Process to force Internet Explorer to exit. We found that when we do this, our plug-in does not receive a DLL_PROCESS_DETACH notification. What could be preventing our plug-in ...
Comments are closed.0 0
Code

Why can't I install this DLL via Regsvr32 /i?

A customer asked for help installing a particular DLL. They ran the command regsvr /i SomeDll.dll but got the error "SomeDll.dll was loaded, but the DllInstall entry point was not found. This file can not be registered." A DLL needs to be specifically written to be used with the regsvr32 command. You can't just grab some random DLL and expect...

Feedback usabilla icon