Showing tag results for Code

Feb 3, 2011
Post comments count0
Post likes count1

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 count1

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 count1

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 count1

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 count1

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
Jan 20, 2011
Post comments count0
Post likes count1

How to turn off the exception handler that COM "helpfully" wraps around your server

Raymond Chen
Raymond Chen

Historically, COM placed a giant around your server's methods. If your server encountered what would normally be an unhandled exception, the giant would catch it and turn it into the error . It then marked the exception as handled, so that the server remained running, thereby "improving robustness by keeping the server running even when it encou...

Code
Jan 14, 2011
Post comments count0
Post likes count1

What's the difference between an asynchronous PIPE_WAIT pipe and a PIPE_NOWAIT pipe?

Raymond Chen
Raymond Chen

When you operate on named pipes, you have a choice of opening them in mode or mode. When you read from a pipe, the read blocks until data becomes available in the pipe. When you read from a pipe, then the read completes immediately even if there is no data in the pipe. But how is this different from a pipe opened in asynchronous mode by passin...

Code
Jan 13, 2011
Post comments count0
Post likes count1

The MARGINS parameter to the DwmExtendFrameIntoClientArea function controls how far the frame extends into the client area

Raymond Chen
Raymond Chen

A customer wrote a program that calls to extend the frame over the entire client area, but then discovered that this made programming difficult: I have a window which I want to have a glassy border but an opaque body. I made my entire window transparent by calling , and I understand that this means that I am now responsible for managing the alpha...

Code
Jan 5, 2011
Post comments count0
Post likes count1

Why does SHGetSpecialFolderPath take such a long time before returning a network error?

Raymond Chen
Raymond Chen

A customer reported that their program was failing to start up because the call to was taking a long time and then eventually returning with . The account that was experiencing this problem had a redirected network profile, "but even if he's redirecting, why would we get the bad net path error? Does calling actually touch the folder/network? If s...

Code