The Old New Thing

The difference between assignment and attachment with ATL smart pointers

Last time, I presented a puzzle regarding a memory leak. Here's the relevant code fragment: The problem here is assigning the return value of to a smart pointer instead of attaching it. The function creates a memory stream and returns a pointer to it. That pointer has a reference count of one, in accordance with COM rules that a ...

We're using a smart pointer, so we can't possibly be the source of the leak

A customer reported that there was a leak in the shell, and they included the output from Application Verifier as proof. And yup, the memory that was leaked was in fact allocated by the shell: On the other hand, is an object creation function, so it's natural that the function allocate some memory. The responsibility for freeing the ...

We found the author of Notepad, sorry you didn't go to the award ceremony

I've received independent confirmations as to the authorship of Notepad, so I'm inclined to believe it. Sorry you didn't get to go to the award ceremony. The original author of Notepad also served as the development manager for Windows 95. His job was to herd the cats that made up the programmers who worked on Windows 95, a job ...

How to tell when your patent has been approved

There are a variety of ways of finding out when your patent is granted, but the quickest mechanism is to check your mailbox. But the thing to look for is not what you might think. Even before you receive word from your company's patent department, you will start receiving junk mail delivered to your home address from companies that sell ...

How to pretend that you attended my talk at UIUC Reflections|Projections 2009

Step 1: Buy a 1.55-ounce Hershey's Milk Chocolate Bar from a convenience store, supermarket, or (if truly desperate) online. Step 2: Print out this candy bar wrapper. Step 3: Trim wrapper on registration marks and wrap around candy bar. Step 4: Stay up late the night before you plan on watching the video by partying with Ryan North ...

Why does shlwapi import a nonexistent function?

Commenter charless asks why shlwapi.dll imports a nonexistent function from mpr.dll, which shows up in dependency tools as a broken import. Because that function did exist at one point, although it doesn't exist any more. The function in question was available only on Windows 95-series versions of Windows. It never existed on Windows&...

What a drag: You can be a drag in managed code, too

David Anson digests my earlier series on virtual drag/drop and translates it into managed code. His example of dragging his entire RSS feed is an excellent illustration of dragging dynamically-generated virtual content. (I didn't use an example like that because the purpose of the What a drag series was to get something done in the least ...