Why does CreateFile take a long time on a volume handle?
A customer reported that on Windows XP, a call to CreateFile was taking a really, really long time if it was performed immediately after a large file copy. They were kind enough to include a...
View ArticleWhy does a single integer assignment statement consume all of my CPU?
Here's a C++ class inspired by actual events. (Yes, the certificate on that Web site is broken.) It is somebody's attempt to create a generic value type, similar to VARIANT. class Value { public:...
View ArticleWhy does Outlook use a semicolon to separate multiple recipients by default?
Microsoft Outlook by default uses a semicolon to separate multiple recipients. You can change this to a comma, but why is the semicolon the default? Microsoft Outlook was originally positioned as a...
View ArticleWhy does the copy dialog give me the incorrect total size of the files being...
If you try to copy a bunch of files to a drive that doesn't have enough available space, you get an error message like this: 1 Interrupted Action There is not enough space on Removable Disk (D:). You...
View ArticleWhy does my synchronous overlapped ReadFile return FALSE when the end of the...
A customer reported that the behavior of ReadFile was not what they were expecting. We have a synchronous file handle (not created with FILE_FLAG_OVERLAPPED), but we issue reads against it with an...
View ArticleThe wonderful world of shell bind context strings
Some time ago, we saw how the IBindCtx parameter to IShellFolder::ParseDisplayName can be used to modify how the parse takes place. More generally, the IBindCtx parameter to a function is a...
View ArticleHelper functions to make shell bind contexts slightly more manageable
Last time, we learned about the wonderful world of shell bind context strings, and I promised some helper functions to make this slightly more manageable. Here are some helper functions which...
View ArticleCustomizing item enumeration with IShellItem
If you are using the original IShellFolder interface, then you can use SHCONTF values to customize how child items are enumerated. But what if you're using IShellItem? Let's take it one step at a...
View ArticleTip for trying to boost morale: Don't brag about your overseas trips
Once upon a time, a senior manager held a team meeting to address low team morale. Attempting to highlight how important the project was, he opened by saying, "I just got back from 〈faraway country〉,...
View ArticleThe compiler can make up its own calling conventions, within limits
A customer was confused by what they were seeing when debugging. It is our understanding that the Windows x86-64 calling convention passes the first four parameters in registers rcx, rdx, r8, and r9....
View ArticleColor-aware ClearType requires access to fixed background pixels, which is a...
ClearType is a technology that blends text pixels with background pixels with the goal of reducing visual artifacts during text rendering.¹ If you go for the full-meal version of ClearType, it uses...
View ArticleCreating a shared memory block that can grow in size
A little-known feature of shared memory blocks in Win32 is that it is possible to resize them, sort of. When you create a shared memory block, you can pass the SEC_RESERVE flag to CreateFileMapping,...
View ArticleGot errands? Now is the time
This upcoming Sunday is the Super Bowl, the championship game for a sport played only in the United States.¹ The entire country stops doing anything when the game is on. This makes it a perfect time...
View ArticleCustomizing item enumeration with IShellItem, the old-fashioned way
If you are targeting Windows 8 or higher, you can use (STR_ENUM_ITEMS_FLAGS to customize how shell items are enumerated. But what if you need to run on older systems, too? In that case, you will need...
View ArticleAnother way to make sure nobody sends you feedback
I wanted to report an issue about a problem with our building, let's say that the widget frobnicators were not working. I went to the internal Widget Frobnicators Web site, and it was very pretty,...
View ArticleIf you wonder why a function can't be found, one thing to check is whether...
One of my colleagues was frustrated trying to get some code to build. "Is there something strange about linking variadic functions? Because I keep getting an unresolved external error for the...
View ArticleThe SuspendThread function suspends a thread, but it does so asynchronously
Prologue: Why you should never suspend a thread. Okay, so a colleague decided to ignore that advice because he was running some experiments with thread safety and interlocked operations, and suspending...
View ArticleUse GFlags to catch the silent killer (silent but deadly)
Suppose you have some process that is mysteriously dying and you can't figure out why. You think that some other process is doing a TerminateProcess but heck if you can figure out who that is....
View ArticleUsing thread pool cleanup groups to clean up many things at once
Today's Little Program demonstrates thread pool cleanup groups. When you associate a thread pool item with a cleanup group, you can perform bulk operations on the group. That can save you a lot of...
View ArticleStaying cool is one of the skills of a corporate president
Some time ago, there was a mechanical problem with the heating/cooling system in our part of the building, and one of the senior managers in our group took the opportunity to tell a story of a...
View Article