C++/WinRT implementation extension points: abi_guard, abi_enter, abi_exit,...
C++/WinRT provides a few extension points for implementations to customize default behavior of inspectable objects. When the last reference to an object is released, the object is destroyed. However,...
View ArticleWhen I tell the file or folder picker that I want only file system files and...
You can ask a file picker dialog to limit itself to files in the file system by passing the FOS_FORCEFILESYSTEM flag. There is an analogous BIF_RETURNONLYFSDIRS flag for the folder picker. But if...
View ArticleWhat’s the difference between the hotkeys F6 and Alt+F6?
Some time ago, I listed some of the historical system hotkeys, and I noted that of the ones on the list, only Alt+F4 and Alt+F6 are still around. You’re probably familiar with Alt+F4. It’s the hotkey...
View ArticleWhy can’t I create a “Please wait” dialog from a background thread to inform...
A customer had a program which performed a long-running operation on its main UI thread. They wanted to display a “Please wait” dialog from a background thread, so they did something like this: void...
View ArticleIf you want to terminate on an unexpected exception, then don’t sniff at...
You’ve probably had to write code that lives at the boundary between exception-based code and error-code-based code. HRESULT ConvertExceptionToHResult() { try { throw; } catch (MyCustomExceptionClass...
View ArticleWhy does FormatMessage say that %0 terminates the message without a trailing...
The documentation for the FormatMessage function says that %0 terminates the message without a trailing newline. Why does there need to be a special format to prevent it from adding a newline? Does it...
View ArticleDid you hear that story about Bill Gates?: A PR person’s view
I learned from someone who did public relations for Bill and Melinda Gates that they often hear stories of the form, “So I heard from a friend of a friend that their cousin’s hairdresser’s former high...
View ArticleIf you suppress GDI+ background thread, then you are expected to pump...
When you initialize GDI+ by calling GdiplusStartup, you can choose to let GDI+ create its own notification thread (also know as the background thread), or you can suppress the notification thread and...
View ArticleThe program “G” is preventing you from shutting down
So you’re trying to sign off or shut down, but you get a message saying that some program named “G” is preventing you. What’s going on? Who is this mysterious “G” program? We noted some time ago that...
View ArticleFor one internal build, Windows 95 contained an evil message
One of the many significant accomplishments of Windows 95 was the widespread adoption of Plug and Play, the idea (borderline heretical at the time) that devices could not only be software-configurable,...
View ArticleWhy does my program crash if I terminate a thread that is waiting to enter a...
A customer had a program that used the TerminateThread function to terminate a thread while it was waiting for a critical section. They claim that this code worked in earlier versions of Windows, but...
View ArticleWhat happened if you tried to access a network file bigger than 2GB from MS-DOS?
One of my friends is into retrocomputing, and he wondered what happened on MS-DOS if you asked it to access a file on a network share that was bigger than what FAT16 could express. My friend was under...
View ArticleI tried to adjust the time on my alarm clock. I failed.
For some reason, my alarm clock requires that I install an app on my phone. And the app required me to create an account. I’m going to repeat that: In order to set my alarm clock, I had to create an...
View ArticleThe legend of Steve Ballmer’s rental car, the most diligent employee in the...
According to legend, Steve Ballmer’s rental car was the most diligent employee in the world. When he was the head of the Systems Division, Steve Ballmer had to go visit various development partners on...
View ArticleHow can I have a C++ function that returns different types depending on what...
Here’s something crazy: You have a function that has two different callers. One of them expects the function to return a widget. The other expects the function to return a doodad. class widget; class...
View ArticleHow can I give a C++ lambda expression more than one operator()?
Suppose you have stored a C++ lambda expression into a variable, and you want to call it in different ways. This seems impossible, because when you define the lambda expression, you can provide only...
View ArticleCan I force a WM_TIMER message to be generated when the timer comes due, even...
Normally, WM_TIMER messages for due timers are generated only if the message queue is empty, which puts them very close to the bottom of the message priority list. But what if you want to give the...
View ArticleThe curious pattern of pre-emptively rejecting the solution to your problem:...
A customer had a program that drew a little bit of content against the right-hand edge of its client area. They found that when the user resized the window from small to large, they got bad rendering:...
View ArticleHow can I copy or move a group of files into a new folder from Explorer?
Here’s how you copy or move a group of files into a new folder. Select the files and folders you want to copy or move. Click the Move to or Copy to button, corresponding to what you want to do. In the...
View ArticleNot even getting to the airtight hatchway: Planting files in world-writable...
A security vulnerability report came in declaring that the finder had discovered an elevation of privilege vulnerability. They explained that they identified a world-writable directory and that an...
View Article