The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Dec 20, 2010
Post comments count 0
Post likes count 1

Developing the method for taking advantage of the fact that the OVERLAPPED associated with asynchronous I/O is passed by address

Raymond Chen

You can take advantage of the fact that the associated with asynchronous I/O is passed by address, but there was some confusion about how this technique could "work" when kernel mode has no idea that you are playing this trick. Whether kernel mode is in on the trick is immaterial since it is not part of the trick. Let's start with a version of the code which does not take advantage of the structure address in the way described in the article. This is a technique I found in a book on advanced Windows programming: This version of the code uses the address of the structure to determine the location in th...

Dec 20, 2010
Post comments count 0
Post likes count 1

What happened to the return code from WinMain in 16-bit Windows?

Raymond Chen

Commenter S asks, "What happened to the return code from WinMain in a Windows 3.1 app?" After all, there was no function in 16-bit Windows. Basically, the exit code vanished into the ether. Unless you captured it. The Toolhelp library provided a low-level hook into various parts of the kernel, allowing you to monitor, among other things, the creation and destruction of tasks. That was how you captured the return code of a Windows program in 16-bit Windows. But if you didn't catch it as it happened, it was gone forever, lost in the ether.

Dec 17, 2010
Post comments count 0
Post likes count 2

The OVERLAPPED associated with asynchronous I/O is passed by address, and you can take advantage of that

Raymond Chen

When you issue asynchronous I/O, the completion function or the I/O completion port receives, among other things, a pointer to the structure that the I/O was originally issued against. And that is your key to golden riches. If you need to associate information with the I/O operation, there's no obvious place to put it, so some people end up doing things like maintaining a master table which records all outstanding overlapped I/O as well as the additional information associated with that I/O. When each I/O completes, they look up the I/O in the master table to locate that additional information. But it's eas...

Dec 16, 2010
Post comments count 0
Post likes count 1

Why does SHCOLUMNINFO have unusually tight packing?

Raymond Chen

Alternate title: News flash: Sometimes things happen by mistake rbirkby asks why the structure has 1-byte packing. "Was the expectation that there would be so many columns in a details view that the saving would be worthwhile?" Hardly anything that clever or ingenious. It's just the consequence of a mistake. When the structure was added to the header file in the Windows 2000 timeframe, it was added with no specific packing directive. But it turns out that there was a specific packing directive; it just wasn't obvious. Near the top of the header file was the following: (There was of course a mat...

Dec 15, 2010
Post comments count 0
Post likes count 1

There is no interface for preventing your notification icon from being hidden

Raymond Chen

Yes, it's another installment of I bet somebody got a really nice bonus for that feature. A customer had this question for the Windows 7 team: Our program creates a notification icon, and we found that on Windows 7 it is hidden. It appears properly on all previous versions of Windows. What is the API to make our icon visible? First of all, I'd like to congratulate you on writing the most awesome program in the history of the universe. Unfortunately, Windows 7 was not prepared for your awesomeness, because there is no way to prevent your notification icon from being hidden. That's because if t...

Dec 14, 2010
Post comments count 0
Post likes count 0

The subtleties of a Will Ferrell movie, and other observations from the in-flight entertainment on a Chinese airline

Raymond Chen

My flights to and from Beijing were on Hainan Airlines, a Chinese airline. One consequence of this is that Mandarin Chinese is the primary language of communication; English is a distant second. It also means that the in-flight movies are subtitled in Chinese, so if you can't read Chinese, you are restricted to movies in languages you understand. I wasn't interested in the English-language movies, although I did watch a little bit of "The Other Guys", a Will Ferrell vehicle. In one scene, Ferrell's character and his friend have dinner in a Chinese restaurant. Ferrell's character says to the waiter, "謝&#35...

Dec 14, 2010
Post comments count 0
Post likes count 1

Microspeak: Informing a product

Raymond Chen

Microspeak is not always about changing a word from a verb to a noun or changing a noun to a verb or even changing a noun into a verb and then back into a noun. Sometimes it's about data compression. This testing won't inform RC, but we'll need it to inform an RTM release. First, you need to familiarize yourself with a less-used sense of the verb to inform, namely to guide or direct. A typical use would be something like "This data will inform the decision whether to continue with the original plan in Product Q." In other words, this data will be used to help decide whether to continue with the origina...

Dec 13, 2010
Post comments count 0
Post likes count 1

Why are the Compression and Encryption options check boxes instead of radio buttons?

Raymond Chen

Tanveer Badar asks why the file properties Advanced dialog shows two checkboxes (compression and encryption) even though NTFS supports only one or the other at a time. "Why not have two radio buttons instead of these silly check boxes?" Actually, if you want radio buttons, you'd need three, one to cover the "neither" case. Let's look at what those radio buttons would look like: Compress contents to save disk space Encrypt contents to secure data Neither compress nor encrypt This takes an implementation detail (that NTFS currently does not support simultaneous compression and encryption) and elevates it to th...

Dec 10, 2010
Post comments count 0
Post likes count 0

Some notes on my trip to Beijing disguised as travel tips

Raymond Chen

Single-use tickets purchased from subway vending machines are valid only on the day of purchase for use in that station. Do not buy your return ticket at the same time as your outbound ticket because it will not work. This detail is clearly explained on the ticket that you receive after you have paid for it. (Also, the vending machine will ask you how many "sheets" you want. It's asking how many tickets you want.) Subway station names are printed in both Chinese and pinyin, but the pinyin omits the tone markers, which means that you will have no idea how you're supposed to pronounce the station name, should anyb...