The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Aug 28, 2013
Post comments count 0
Post likes count 1

The format of data and custom resources

Raymond Chen

Continuing the highly-sporadic series of Win32 resource formats, today we'll look at the format of resources, which are declared in resource files as . Also the format of custom resources, which are declared in resource files by just giving the custom resource name or ordinal as the second word on the declaration. The format is very simple: It's just raw binary data. If you ask for a 16-bit integer followed by an ANSI string, then you get a 16-bit integer followed by an ANSI string. If you ask for the data to be inserted from a file, then the contents of the file become the resource data. No processing is done...

Aug 27, 2013
Post comments count 0
Post likes count 1

How can I find out which process and user is modifying a file?

Raymond Chen

When troubleshooting a problem, you may discover that a file is being modified that shouldn't, and you figure out would be nice if there were some way of finding out which process is modifying the file (so you can get it to stop). Enter the security auditing system. Every securable object has an associated system access control list (SACL) which controls what audit events are raised when a request is made to access the object. You can say, for example, "Log an event in the security event log if somebody tries to open this file for writing but is denied access," or "Log an event in the security event log if some...

Aug 26, 2013
Post comments count 0
Post likes count 1

The challenge of improvisational historical comedy

Raymond Chen

I dreamed that one of my friends signed me up for some sort of combination Punk'd/Thank God You're Here improv show without my knowledge, and I had to explain how her husband had unwittingly coined some nonspecific Internet meme.

Aug 26, 2013
Post comments count 0
Post likes count 1

Why doesn't the "Automatically move pointer to the default button in a dialog box" work for nonstandard dialog boxes, and how do I add it to my own nonstandard dialog boxes?

Raymond Chen

The Mouse control panel has a setting called Automatically move pointer to the default button in a dialog box, known informally as Snap to default button or simply Snap To. You may have discovered that it doesn't work for all dialog boxes. Why not? The Snap To feature is implemented by the dialog manager. When the window is shown and the setting is enabled, it will center the pointer on the default button. If your application does not use the dialog manager but instead creates its own custom dialog-like windows, then naturally the code in the standard dialog manager will not run. If you want your nonstandard...

Aug 23, 2013
Post comments count 0
Post likes count 1

If I attach a file to an existing completion port, do I have to close the completion port handle a second time?

Raymond Chen

There are two ways of calling the function. You can pass a null pointer as the parameter, indicating that you would like to create a brand new completion port, associated with the file handle you passed (if you passed one). Or you can pass the handle of an existing completion port, and the file handle you passed will be associated with that port, in addition to whatever other file handles are already associated with that port. In both cases, the return value on success is a handle to the I/O completion port, either the brand new one or the existing one. The question from a customer was, "In the case where I...

Aug 22, 2013
Post comments count 0
Post likes count 1

All I/O on a synchronous file handle is serialized; that's why it's called a synchronous file handle

Raymond Chen

File handles are synchronous by default. If you want asynchronous file handles, you need to pass the flag when you create the handle. And all operations on a synchronous file handle are serialized. You'd think this was a simple and obvious rule, but "Someone" finds it "very surprising that operations can block which only handle file metadata." Imagine if synchronous file handles were not serialized for metadata operations. First of all, it means that the documentation for synchronous file handles suddenly got a lot more complicated. "Some operations on synchronous file handles are serialized, but not others. S...

Aug 21, 2013
Post comments count 0
Post likes count 1

Adding a confirmation dialog to every drag/drop operation does not solve the problem

Raymond Chen

A customer wanted to know how to enable a confirmation dialog whenever the user inadvertently perform a drag/drop operation in Explorer to move files within a volume. For example, if I have an S drive mapped to \\server\share, I would like to display the confirmation dialog when users inadvertently drag and drop a file or folder within the S drive. Okay, first of all, the problem statement doesn't match the question. But that's good, because the question was misguided. The question was "How do I add a confirmation dialog to every drag/drop operation?" But the problem statement was "We have users who inadverte...

Aug 20, 2013
Post comments count 0
Post likes count 1

Microspeak: The train

Raymond Chen

Hop on board, don't be late, or you'll have to catch the next one.

Aug 19, 2013
Post comments count 0
Post likes count 1

A dream about forgetting to deploy the backup brake pads

Raymond Chen

I dreamed that that I was driving through a parking garage when my brakes suddenly failed. I tried executing turns to bleed off speed, but it was largely ineffective. I managed to avoid hitting a parked police car (which had arrived to investigate some other accident), but was unable to avoid another parked car. An insurance adjuster who was on the scene for the first accident looked at my car and discovered that my primary brake pads were completely missing, so the calipers were grabbing air. And in my panic, it never occurred to me to use my left foot to push the button which hot-installs the secondary brake p...