The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts

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 length, not counting the terminating null. Therefore, the correct buffer size is 12 bytes, but they passed only 11 to . This error is compounded in the code that reads the value back: The code happily divides without checking that the division is even. In our example, the c...

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 to see if there's updated online help content related to your search. And the people who develop the online help content look over those queries to see if, for example, there is a category of issues people are searching for help with and not finding anything. It also means ...

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 invented now or in the future. On the other hand, the shell common control imposed enough limits on the type of AVIs it could handle to the point where what was left was extremely lightweight, certainly much more lightweight than an animated GIF. Think about it: To use an animat...

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 to force Internet Explorer to exit. We found that when we do this, our plug-in does not receive a notification. What could be preventing our plug-in from receiving the notification? As we saw some time ago when we looked at the way processes shut down (plus an important follow-up or two), all a process has to do to thwart proper delivery of notifications is to do something untoward during shutdown, at which point the kernel just gives up and calls...

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

A customer asked for help installing a particular DLL. They ran the command 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 command. You can't just grab some random DLL and expect to work. As we saw last week, the program merely loads the specified DLL and calls an entry point established by convention. If the DLL was not written to be used with then the conventional entry point will not be found, and you get an error message. The switch to instructs the program to look f...

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-forth¹ we manage to tease the real question out of the customer: How can I tell whether a COM pointer to a remote object is still valid? The easy answer is "Don't worry. COM will take care of it." Just call the method on the object. If the remote object is not valid, ...

Fontography term or pretentious blather?

Fontography is like wine. The connoisseurs speak in a language that only superficially resembles English. Here's a list of words. Which of them are terms used in fontography, and which are just pretentious blather? If you aren't familiar with font speak, here's a sample I stole from an old article on the evolution of the Internet explorer logo: In The Elements of Typographic Style by Robert Bringhurst, "this typeface is described as a heavy un-modulated line and tiny aperture (which) evoke an image of uncultivated strength, force and persistence." Bonus link: Cheese or Font?

The challenges in changing the way Explorer hosts shell extensions

Various types of shell extensions such as thumbnail extractors are run in a separate process, and if one of those shell extensions crashes, it takes out the COM Surrogate rather than the main Explorer process. Anonymous wondered if this model could be extended to all types of shell extensions, perhaps not all at once, but gradually. The dangers of extending this model to existing shell extensions are compatibility (of course) and re-entrancy. The thumbnail extractor interface was lucky in that the only parameter an extractor received was an representing the object for which the caller wishes to retrieve a t...

Stupid Raymond talent: Screaming carrier

Similar to Mike, I was able to scream (not whistle: scream) a 300 baud carrier tone. This skill proved useful when I was in college and the mainframe system was down. Instead of sitting around waiting for the system to come back, I just went about my regular business around campus. Every so often, I would go to a nearby campus phone (like a free public phone but it can only make calls to other locations on campus), dial the 300 baud dial-up number, and scream the carrier tone. If I got a response, that meant that the mainframe was back online and I should wrap up what I was doing and head back to the lab. Mind ...