Showing archive results for 2010

Oct 25, 2010
Post comments count0
Post likes count1

Belated happy first birthday, Windows 7

Raymond Chen
Raymond Chen

On Friday, the marketing folks informed me that they decided to put me on the Microsoft Careers United States home page in recognition of Windows 7's first birthday. It's an honor and to be honest a bit scary to be chosen to be the face of Windows on a day of such significance. (They told me that had narrowed it down to me and "some Directo...

Non-Computer
Oct 25, 2010
Post comments count0
Post likes count1

When you call a function, your code doesn't resume execution until that function returns

Raymond Chen
Raymond Chen

Consider this code fragment: When calls , and has not yet returned, does continue executing? Does get called before returns? No, it does not. The basic structure of the C/C++ language imposes sequential execution. Control does not return to the function until returns control, either by reaching the end of the function or by an explic...

Code
Oct 22, 2010
Post comments count0
Post likes count2

The evolution of the ICO file format, part 4: PNG images

Raymond Chen
Raymond Chen

We finish our tour of the evolution of the ICO file format with the introduction of PNG-compressed images in Windows Vista. The natural way of introducing PNG support for icon images would be to allow the field of the to take the value , in which case the image would be represented not by a DIB but by a PNG. After all, that's why we have a ...

Other
Oct 21, 2010
Post comments count0
Post likes count1

The evolution of the ICO file format, part 3: Alpha-blended images

Raymond Chen
Raymond Chen

Windows XP introduced the ability to provide icon images which contain an 8-bit alpha channel. Up until this point, you had only a 1-bit alpha channel, represented by a mask. The representation of an alpha-blended image in your ICO file is pretty straightforward. Recall that the old ICO format supports 0RGB 32bpp bitmaps. To use an alpha-blen...

Other
Oct 20, 2010
Post comments count0
Post likes count1

How do I get the dimensions of a cursor or icon?

Raymond Chen
Raymond Chen

Given a or a , how do you get the dimensions of the icon or cursor? The function gets you most of the way there, returning you an structure which gives you the mask and color bitmaps (and the hotspot, if a cursor). You can then use the function to get the attributes of the bitmap. And then here's the tricky part: You have to massage the data...

Code
Oct 19, 2010
Post comments count0
Post likes count1

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
Post comments count0
Post likes count1

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
Post comments count0
Post likes count1

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
Post comments count0
Post likes count1

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
Post comments count0
Post likes count1

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