Showing results for October 2010 - Page 2 of 3 - The Old New Thing

Oct 19, 2010
0
0

The evolution of the ICO file format, part 2: Now in color!

Raymond Chen
Raymond Chen

Last time, we looked at the format of classic monochrome icons. But if you want to include color images, too? (Note that it is legal—and for a time it was common—for a single ICO file to offer both monochrome and color icons. After all, a single ICO file can offer both 16-color and high-color images; why not also 2-color images?) The representati...

Other
Oct 18, 2010
0
0

The evolution of the ICO file format, part 1: Monochrome beginnings

Raymond Chen
Raymond Chen

This week is devoted to the evolution of the ICO file format. Note that the icon resource format is different from the ICO file format; I'll save that topic for another day. The ICO file begins with a fixed header: must be zero, and must be 1. The describes how many images are included in this ICO file. An ICO file is really a collection o...

Other
Oct 15, 2010
0
0

What does the FOF_NOCOPYSECURITYATTRIBS flag really do (or not do)?

Raymond Chen
Raymond Chen

In the old days, the shell copy engine didn't pay attention to ACLs. It just let the file system do whatever the default file system behavior was. The result was something like this: Perfectly logical, right? If a new file is created, then the security attributes are inherited from the container. If an existing file is moved, then its security a...

Code
Oct 14, 2010
0
0

The memcmp function reports the result of the comparison at the point of the first difference, but it can still read past that point

Raymond Chen
Raymond Chen

This story originally involved a more complex data structure, but that would have required too much explaining (with relatively little benefit since the data structure was not related to the moral of the story), so I'm going to retell it with double null-terminated strings as the data structure instead. Consider the following code to compare tw...

Code
Oct 13, 2010
0
0

How do I get the color depth of the screen?

Raymond Chen
Raymond Chen

How do I get the color depth of the screen? This question already makes an assumption that isn't always true, but we'll answer the question first, then discuss why the answer is wrong. If you have a device context for the screen, you can query the color depth with a simple arithmetic calculation: Now that you have the answer, I'll explain why...

Code
Oct 11, 2010
0
0

Why does each drive have its own current directory?

Raymond Chen
Raymond Chen

Commenter Dean Earley asks, "Why is there a 'current directory' AND an current drive? Why not merge them?" Pithy answer: Originally, each drive had its own current directory, but now they don't, but it looks like they do. Okay, let's unwrap that sentence. You actually know enough to answer the question yourself; you just have to put the pieces...

History
Oct 8, 2010
0
0

Why does TaskDialog return immediately without showing a dialog? – Answer

Raymond Chen
Raymond Chen

Last time, I left an exercise to determine why the function was not actually displaying anything. The problem had nothing to do with an invalid window handle parameter and had all to do with original window being destroyed. My psychic powers told me that the window's handler called . As we learned some time ago, quit messages cause modal loop...

Code
Oct 8, 2010
0
0

Why does my asynchronous I/O request return TRUE instead of failing with ERROR_IO_PENDING?

Raymond Chen
Raymond Chen

A customer reported that their program was not respecting the flag consistently: My program opens a file handle in mode, binds it to an I/O completion callback function with , and then issues a against it. I would expect that the returns and returns , indicating that the I/O operation is being performed asynchronously, and that the completio...

Code
Oct 7, 2010
0
0

The overlooked computer room at school that became my "office" for a while

Raymond Chen
Raymond Chen

VIMH's comment on an unmarked restroom that is largely unknown reminds me of a story from my college days. Since my final project involved computational geometry, I was granted a key to the rooms in our department which had the computers with fancy graphical displays. (The term "fancy graphical display" is a relative one, mind you. By today's sta...

Non-Computer