Showing results for Code - The Old New Thing

Jul 16, 2010
Post comments count0
Post likes count0

How do I launch the Explorer Search window with specific search criteria?

Raymond Chen
Raymond Chen

A customer wanted to know how to launch Explorer's Search window with specific fixed search criteria. It turns out that there are two ways of doing this, the poor man's way and the overachiever's way. The overachiever's way is actually easier to discover. You can use the search-ms protocol to generate a command string that describes the query you...

Code
Jul 9, 2010
Post comments count0
Post likes count0

What's the difference between LastWriteTime and ChangeTime in FILE_BASIC_INFO?

Raymond Chen
Raymond Chen

The structure contains a number of fields which record the last time a particular action occurred. Two of the fields seem to describe the same thing. Last­Write­Time The time the file was last written to. Change­Time The time the file was changed. What's the difference between writing to a file and changing it? I'm told that th...

Code
Jul 2, 2010
Post comments count0
Post likes count0

Instead of trying to figure out what shortcut class to use, just ask the shell to do it for you

Raymond Chen
Raymond Chen

If a shell namespace item has the attribute, then it is a shortcut to another location. The most common type of shortcut is the file, which you can load by creating the object and using , but what if you have some other type of shortcut? How do you know what CLSID to use? Since anybody can create their own shortcut file types, a hard-coded li...

Code
Jul 1, 2010
Post comments count0
Post likes count0

What is the lpClass member of SHELLEXECUTEINFO used for?

Raymond Chen
Raymond Chen

A customer reported problems launching the default Web browser with the function: This fails with . If you don't pass the flag and leave , then the function will try to figure out what your refers to, looking at the file extension, looking for the file on the , and if all else fails, trying some autocorrection. In this case, the customer...

Code
Jun 28, 2010
Post comments count0
Post likes count0

How do I get a radio button control to render its text transparently?

Raymond Chen
Raymond Chen

Commenter Andrei asks via the Suggestion Box for help with making the text transparent using . "Instead of the radio button now there's a black background." Let's look at this problem in stages. First, let's ignore the transparent part and figure out how to render text without a black background. The background color of the text comes from the ...

Code
Jun 14, 2010
Post comments count0
Post likes count0

Annotating function parameters and using PREfast to check them

Raymond Chen
Raymond Chen

Via the suggestion box, Sys64738 asks, whether I think is a good C/C++ programming style to add IN and OUT to function prototypes. Remember, this is my opinion. Your opinion may validly differ. I would go beyond just IN and OUT and step up to SAL annotations, which describe the semantics of function parameters in more detail than simply IN and ...

Code
Jun 11, 2010
Post comments count0
Post likes count0

How do I indicate that I want my window to follow right-to-left layout rules?

Raymond Chen
Raymond Chen

There are many ways, depending on how wide a scope you want. If there is one specific window that you want to follow right-to-left layout rules, then you pass the extended window style when you create the window. This extended style is inherited by child windows, so once you set a top-level window to have right-to-left layout, all child windows w...

Code
Jun 4, 2010
Post comments count0
Post likes count3

How do I enable and disable the minimize, maximize, and close buttons in my caption bar?

Raymond Chen
Raymond Chen

A customer was having problems with the small icon that appears in the upper left corner of the caption: In my program, I need to enable and disable the Close button programmatically, since the program sometimes goes into a state where I don't want the user to close it. I do this by removing the style when I want to disable the Close button, an...

Code
Jun 1, 2010
Post comments count0
Post likes count0

Why doesn't the Windows Vista copy progress dialog show the names of the files being copied?, redux

Raymond Chen
Raymond Chen

As expected, everybody concluded that the Windows Vista copy progress dialog made every wrong decision possible. Let's look at some of the suggestions on making it suck less: Why not update the file name every five seconds to the file that is being copied at that time? Sure, you could do that, but the cost of getting the name is part of the prob...

Code