Showing tag results for Code

Aug 10, 2009
Post comments count0
Post likes count0

Why doesn't String.Format throw a FormatException if you pass too many parameters?

Raymond Chen
Raymond Chen

Welcome to CLR Week 2009. As always, we start with a warm-up. The method doesn't throw a if you pass too many parameters, but it does if you pass too few. Why the asymmetry? Well, this is the type of asymmetry you see in the world a lot. You need a ticket for each person that attends a concert. If you have too few tickets, they won't let you...

Code
Aug 7, 2009
Post comments count0
Post likes count0

SHCIDS_CANONICALONLY is the moral equivalent in the shell namespace of the Unicode ordinal comparison

Raymond Chen
Raymond Chen

One of the flags you can pass to the method is . This flag means that the method should determine whether the two pointers refer to the same underlying object, and if they do not, then it should determine which one should come first by whatever mechanism it wants. It doesn't matter which one is declared as coming before the other one, as long as...

Code
Aug 6, 2009
Post comments count0
Post likes count0

The great thing about regular expression engines is that there are so many to choose from

Raymond Chen
Raymond Chen

Back in the days before perl ruled the earth, regular expressions were one of those weird niche features, one of those things that everybody reimplements when they need it. If you look at the old unix tools, you'll see that even then, there were three different regular expression engines with different syntax. You had , , and . Probably more. The ...

Code
Aug 4, 2009
Post comments count0
Post likes count0

Programming means that sometimes you have to snap two blocks together

Raymond Chen
Raymond Chen

Part of the challenge of programming (and for some people, the reason why programming is fun in the first place) is looking at the building blocks provided to you and deciding how to assemble them to build something new. After all, if everything you wanted a program to do already existed ready-made, it wouldn't be called programming any more. It wo...

Code
Jul 31, 2009
Post comments count0
Post likes count0

What is the difference between Directory and DirectoryBackground?

Raymond Chen
Raymond Chen

One item I left off the list of special progids is . Recall that is the progid for file system folders (a subset of which represents all shell folders, both file system and virtual). Closely related is , which isn't really a progid, but it is a place where shell extensions can register themselves. Specifically, it's where context menu handlers...

Code
Jul 30, 2009
Post comments count0
Post likes count0

What is the difference between CSIDL_DESKTOP and CSIDL_DESKTOPDIRECTORY?

Raymond Chen
Raymond Chen

Among the various values you can pass to functions like are and . What's the difference between them? The is the virtual folder that represents the desktop. The contents of this virtual folder is what gets displayed on top of your wallpaper. The virtual folder is populated from various locations, some of them virtual, and some of them physic...

Code
Jul 27, 2009
Post comments count0
Post likes count0

Polling by sleeping versus polling by waiting with a timeout

Raymond Chen
Raymond Chen

Commenter Francois Boucher asks it's better to write a background worker thread that polls with and a flag, or polls by waiting for an event with a timeout? "Which scenario is better? The first one uses only 1 handle for the thread. The second one will use 2. But is the first scenario wasting more thread time? Is it worth using the event (ker...

Code
Jul 24, 2009
Post comments count0
Post likes count0

If you wished a language supported the preprocessor, you know, you can fix that

Raymond Chen
Raymond Chen

A customer had the following question about the message compiler, something that I had noted almost nobody uses. Well how do you do, we found somebody who actually uses it. Anyway, the question went like this (paraphrased, as always): Can I use symbolic constants in my .mc file? For example, I have a message file that goes like this: I hav...

Code
Jul 17, 2009
Post comments count0
Post likes count0

The disembodiment of DIBs from the DIB section

Raymond Chen
Raymond Chen

So far this week, we've separated the DIB metadata () from the pixels of a DIB section. But there's really no need for the DIB section at all! As long as you have the pixels and the metadata, you can draw bits. We demonstrate this by drawing a rather stupid-looking bitmap onto the screen, but doing so without the use of s at all! Start with a b...

Code
Jul 16, 2009
Post comments count0
Post likes count0

Caption contest: The pinball machine: Results

Raymond Chen
Raymond Chen

It's been quite a while, but a winner in the caption contest has been selected and the prize finally reached its destination. (Mostly due to procrastination on my part. Don't blame the postal service.) The winner is Scott from Australia with his entry Only 5,000 more referrals until MULTIBALL Even though it's kind of low-brow, it made me lau...

Code