Showing results for Code - The Old New Thing

Dec 12, 2011
Post comments count0
Post likes count0

What is the API for accessing content on SkyDrive?

Raymond Chen
Raymond Chen

The last time I mentioned programmatic access to SkyDrive was last June, where I noted that the interface was given the confusing name Messenger Connect. At least now they renamed it to Live Connect, which is slightly less confusing. The SkyDrive folks have been pretty busy lately. A few days ago, Dare Obasanjo announced a new Live Connect SDK,...

Code
Dec 12, 2011
Post comments count0
Post likes count0

How can I tell whether a window is modal?

Raymond Chen
Raymond Chen

A customer wanted a way to determine whether a particular window is modal. They listed a few methods they had tried but found that it didn't work and asked for assistance. As Eric Lippert is fond of saying, "First, write your spec." Until you know what you want, you won't know how to get it. First, you need to define what you mean by a modal w...

Code
Dec 9, 2011
Post comments count0
Post likes count1

Sure, I'm supposed to pass WT_EXECUTELONGFUNCTION if my function takes a long time, but how long is long?

Raymond Chen
Raymond Chen

A customer contacted me to tell a story and ask a question. The customer discovered that in their code base, all calls to passed the flag, regardless of whether the function actually took a long time or not. Their program creates a large number of work items at startup, and the result of passing for all of them was that the thread pool created a...

Code
Dec 8, 2011
Post comments count0
Post likes count0

What does it mean when my program exits with the message "This application has requested the Runtime to terminate it in an unusual way"?

Raymond Chen
Raymond Chen

You're running your program, and then it suddenly exits with the message This application has requested the Runtime to terminate it in an unusual way. What happened? That message is printed by the C runtime function , the same function that also causes your program to terminate with exit code 3. Your program might call explicitly, or it m...

Code
Dec 7, 2011
Post comments count0
Post likes count0

GetParent, just as confusing as EnumClaw, but it's an actual function!

Raymond Chen
Raymond Chen

The function , documented as returning "the child or the parent of the window", was a joke, but there's a function whose behavior is just as confusing as the joke function : . The function returns the parent window, or owner window, or possibly neither. All that's left is for it to be a floor wax and it'll have everything covered. The idea behi...

Code
Dec 5, 2011
Post comments count0
Post likes count0

Why does my program still show up in the Programs and Features folder after my uninstaller exits?

Raymond Chen
Raymond Chen

A customer reported that they were having problems with their program entry in the Programs and Features folder (formerly known as Add and Remove Programs, formerly known as Add/Remove Programs). When the user goes to the Programs and Features folder, selects their program, and clicks Uninstall, the uninstaller runs, but after the uninstaller exits...

Code
Dec 2, 2011
Post comments count0
Post likes count0

Don't let more than one process try to read from stdin at the same time

Raymond Chen
Raymond Chen

A customer reported a problem with a program that ran a series of other programs in parallel. We have a main program (call it main.exe) that runs a bunch of child processes with stdout and stderr redirected. (We are not redirecting stdin.) We've found that some of the child processes get stuck inside the C runtime startup code on a call to on the...

Code
Nov 30, 2011
Post comments count0
Post likes count0

If you protect a write with a critical section, you may also want to protect the read

Raymond Chen
Raymond Chen

It is common to have a critical section which protects against concurrent writes to a variable or collection of variables. But if you protect a write with a critical section, you may also want to protect the read, because the read might race against the write. Adam Rosenfield shared his experience with this issue in a comment from a few years ...

Code
Nov 25, 2011
Post comments count0
Post likes count0

How to insert a large number of items into a treeview efficiently

Raymond Chen
Raymond Chen

Just a quick tip today. If you need to insert a large number of items into a treeview, like tens of thousands, then it's much more efficient to insert them "backwards". (I'm ignoring for now the usability question of having a treeview that large in the first place.) In other words, instead of do it this way: Why is backwards-insertion faster...

Code
Nov 24, 2011
Post comments count0
Post likes count0

How can I extend the deadline for responding to the PBT_APMSUSPEND message?

Raymond Chen
Raymond Chen

A customer observed that starting in Windows Vista, the deadline for responding to the message was reduced from twenty seconds to two seconds. Their program needs more than two seconds to prepare for a suspend and they wanted to know how they could extend the deadline. The program communicates with a device, and if they don't properly prepare the...

Code