The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Mar 17, 2015
Post comments count 0
Post likes count 4

Microspeak: Headcount, req, and related personnel terms

Raymond Chen

Jargon from the personnel side of the business.

Mar 16, 2015
Post comments count 0
Post likes count 1

Does the CLR really call CoInitializeEx on the first call to unmanaged code, even if you don't deal with COM at all and are just calling native code via p/invoke?

Raymond Chen

Some time ago, I called out this part of the documentation regarding managed and unmanaged threading: On the first call to unmanaged code, the runtime calls Co­Initialize­Ex to initialize the COM apartment as either an MTA or an STA apartment. You can control the type of apartment created by setting the System.Threading.ApartmentState property on the thread to MTA, STA, or Unknown. Commenter T asks, "Does it do this even if you don't deal with COM at all and call native code through a P/Invoke?" Well, the documentation says it does, and we can confirm with an experiment: Run this program with...

Mar 13, 2015
Post comments count 0
Post likes count 1

Debugging walkthrough: Access violation on nonsense instruction, episode 2

Raymond Chen

Dueling debuggers.

Mar 12, 2015
Post comments count 0
Post likes count 1

Under what conditions will the IUnknown::AddRef method return 0?

Raymond Chen

When it's lying.

Mar 11, 2015
Post comments count 0
Post likes count 1

Dubious security vulnerability: Copying a program and running the copy

Raymond Chen

Code execution results in code execution.

Mar 10, 2015
Post comments count 0
Post likes count 1

The more times you use the word "simply" in your instructions, the more I suspect you don't know what that word means

Raymond Chen

I was helping somebody look up how to enable frobbing for widgets, and I found one set of instructions on a blog somewhere. To be honest, this happened long enough ago that I forgot what it was exactly, but here's something that captures the general spirit: First, check whether your widget supports frobbing. To do this, simply run this command where is the voodoo code for your widget. It will say "frob supported" if your widget supports frobbing. If you don't know your widget's voodoo code, you can get a list of the voodoo codes and enchantment numbers for all the widgets connected to your computer by s...

Mar 9, 2015
Post comments count 0
Post likes count 1

How can I programmatically resize a listview column to fit its contents?

Raymond Chen

ListView_SetColumnWidth.

Mar 6, 2015
Post comments count 0
Post likes count 1

A question about the FileTimeToLocalFileTime function turned out to be something else

Raymond Chen

Negative time.

Mar 5, 2015
Post comments count 0
Post likes count 1

Modifying the CS_NOCLOSE style does affect all windows of the class, just not necessarily in an immediately noticeable way

Raymond Chen

It's there, you just can't see it.