The Old New Thing

What’s the guidance on when to use rundll32? Easy: Don’t use it

Occasionally, a customer will ask, "What is Rundll32.exe and when should I use it instead of just writing a standalone exe?" The guidance is very simple: Don't use rundll32. Just write your standalone exe. Rundll32 is a leftover from Windows 95, and it has been deprecated since at least Windows Vista because it violates a lot of ...

Why does my program run really slow or even crash (or stop crashing, or crash differently) if running under a debugger?

More than once, a customer has noticed that running the exact same program under the debugger rather than standalone causes it to change behavior. And not just in the "oh, the timing of various operations changed to hit different race conditions" but in much more fundamental ways like "my program runs really slow" or "my program crashes in a ...

What do HeapLock and HeapUnlock do, and when do I need to call them?

You never need to call the and functions under normal operation. Assuming the heap is serialized (which is the default), all the standard heap functions like and will automatically serialize. In fact, the way they serialize is by calling the¹ and functions! Nearly all heap operations complete in a single call. If your heap is ...

What is so special about the instance handle 0x10000000?

A customer wanted to know what it means when the function returns the special value . Um, it means that the library was loaded at ? Okay, here's some more information: "We're trying to debug an application which loads DLLs and attempts to hook their registry accesses when they call . It looks like when the special handle is returned from , ...

What is the proper handling of WM_RENDERFORMAT and WM_RENDERALLFORMATS?

Jeremy points out that the documentation for says that the clipboard owner must not call when responding to the and messages. On the other hand, the documentation for says that the owner must call and . Which is it? It's none of them! Let's start with . The reference implementation for a handler goes like this, with all error ...

Why do I sometimes get classic buttons and sometimes themed buttons depending on the host process?

A customer reported that their printer configuration property sheet page looked different depending on the host process. In some processes, the printer configuration dialog had the classic look of Windows 2000, but in other processes it has the themed look of Windows XP and later versions. The printer driver calls the to create the...

Why doesn't SHGetKnownFolderPath return the customized path?

A customer reported that the function was not working correctly. They moved their Videos folder to a new location, but when they called , they got the old path rather than the new one. A quick check of the code they provided showed why: Um, you're passing the flag. That flag means "Tell me where this folder would have been if its ...

Like the cake, WS_EX_TRANSPARENT is a lie, or at least not the entire truth

There is an extended window style known as . Explaining what this style does is kind of difficult, but it's been on the list of future topics since 2003. Better late than never, I guess. First of all, there are two unrelated senses of transparent in play. One is visual transparency: Pixels beneath the window can show through. The other is ...

Why is it possible to create a toolbar with the wrong HINSTANCE? And what's the right HINSTANCE anyway?

A customer observed that all of the following code fragments are successful in creating a toolbar common control: Furthermore, the customer observed that works regardless of whether you pass the process instance or for the parameter. First of all, what's going on? And second of all, which of the three methods above is most correct...