Showing tag results for Code

Feb 11, 2011
Post comments count0
Post likes count0

How do specify that a shortcut should not be promoted as newly-installed on the Start menu?

Raymond Chen
Raymond Chen

Windows XP employed a number of heuristics to determine which Start menu shortcuts should be promoted when an application is newly-installed. But what if those heuristics end up guessing wrong? You can set the property to to tell the Start menu, "I am not the primary entry point for the program; I'm a secondary shortcut, like a help file." ...

Code
Feb 9, 2011
Post comments count0
Post likes count0

Why does SHGetKnownFolderPath return E_FAIL for a known folder?

Raymond Chen
Raymond Chen

A customer reported having problems with the function. I've left in the red herrings. On Windows 7, I'm trying to retrieve the Internet folder with the following code: The call always fails with . What am I doing wrong? I tried passing as the token, but that didn't help. The reason the call fails has nothing to do with Windows ...

Code
Feb 7, 2011
Post comments count0
Post likes count0

The cursor isn't associated with a window or a window class; it's associated with a thread group

Raymond Chen
Raymond Chen

In my earlier discussion of the fact that changing a class property affects all windows of that class, commenters LittleHelper and Norman Diamond wanted to know "Why is the cursor associated with class and not a window?" This is another one of those questions that start off with an invalid assumption. The cursor is not associated with a class. ...

Code
Feb 4, 2011
Post comments count0
Post likes count1

Ready… cancel… wait for it! (part 3)

Raymond Chen
Raymond Chen

A customer reported that their application was crashing in RPC, and they submitted a sample program which illustrated the same crash as their program. Their sample program was actually based on the AsyncRPC sample client program, which was nice, because it provided a mutually-known starting point. They made quite a few changes to the program, but ...

Code
Feb 3, 2011
Post comments count0
Post likes count0

Ready… cancel… wait for it! (part 2)

Raymond Chen
Raymond Chen

A customer had a question about I/O cancellation. They have a pending call with a completion procedure. They then cancel the I/O with and wait for the completion by passing as the parameter to . Assuming both return success, can I assume that my completion procedure will not be called after GetOverlappedResult returns? It appears that GetOverl...

Code
Feb 2, 2011
Post comments count0
Post likes count0

Ready… cancel… wait for it! (part 1)

Raymond Chen
Raymond Chen

One of the cardinal rules of the structure is the structure must remain valid until the I/O completes. The reason is that the structure is manipulated by address rather than by value. The word complete here has a specific technical meaning. It doesn't mean "must remain valid until you are no longer interested in the result of the I/O." It me...

Code
Jan 27, 2011
Post comments count0
Post likes count0

How do you obtain the icon for a shortcut without the shortcut overlay?

Raymond Chen
Raymond Chen

The easy one-stop-shopping way to get the icon for a file is to use the function with the flag. One quirk of the function is that if you pass the path to a shortcut file, it will always place the shortcut overlay on the icon, regardless of whether you passed the flag. (Exercise: What is so special about the shortcut overlay that makes it exemp...

Code
Jan 24, 2011
Post comments count0
Post likes count0

There's a default implementation for WM_SETREDRAW, but you might be able to do better

Raymond Chen
Raymond Chen

If your window doesn't have a handler for the message, then will give you a default implementation which suppresses messages for your window when redraw is disabled, and re-enables (and triggers a full repaint) when redraw is re-enabled. (This is internally accomplished by making the window pseudo-invisible, but that's an implementation detail...

Code
Jan 21, 2011
Post comments count0
Post likes count0

Modality, part 9: Setting the correct owner for modal UI, practical exam

Raymond Chen
Raymond Chen

Here's a question that came from a customer. You can answer it yourself based on what you know about modal UI. (If you're kind of rusty on the topic, you can catch up here.) I've left in some irrelevant details just to make things interesting. Our program launches a helper program to display an Aero Wizard to guide the user through submitting ...

Code