The Old New Thing

When you have a SAFEARRAY, you need to know what it is a SAFEARRAY *of*

A customer had a problem with SAFEARRAY, or more specifically, with CComSafeArray. CComSafeArray<VARIANT> sa; GetAwesomeArray(&sa); LONG lb = sa.GetLowerBound(); LONG ub = sa.GetUpperBound(); for (LONG i = lb; i <= ub; i++) { CComVariant item = sa.GetAt(i); ... use the item ... } The GetAt method returns a VARIANT&, ...

What is this rogue version 1.0 of the HTML clipboard format?

At least as of the time this article was originally written, the HTML clipboard format is officially at version 0.9. A customer observed that sometimes they received HTML clipboard data that marked itself as version 1.0 and wanted to know where they could find documentation on that version. As far as I can tell, there is no official ...

How do I create a TaskDialog with a progress bar but no cancel button?

A developer from another group within Microsoft wanted to create a with a progress bar, but they couldn't figure out how to get rid of the Cancel button. "Is there a way to remove all the buttons from a Task Dialog?" Um, users hate it when you give them a window that cannot be closed or cancelled. What should the user do if the ...

How can I write a script that finds my top-rated photos?

I'm not sure if I'll be able to keep it up, but I'm going to see if I can make Monday "Little Programs" day, where I solve simple problems with little programs. Today's little program is a script that goes through your Pictures folder and picks out your top-rated photos. The key step here is extracting the rating, which goes by the name ...

Understanding errors in classical linking: The delay-load catch-22

Wrapping up our week of understanding the classical model for linking, we'll put together all the little pieces we've learned this week to puzzle out a linker problem: The delay-load catch-22. You do some code cleanup, then rebuild your project, and you get LNK4199: /DELAYLOAD:SHLWAPI ignored; no imports found from SHLWAPI What does ...

Understanding the classical model for linking: Sometimes you don’t want a symbol to come along for a ride

Continuing our study of the classical model for linking, let's take another look at the trick of taking symbols along for the ride. The technique of taking symbols along for the ride is quite handy if that's what you want, but sometimes you don't actually want it. For example, a symbol taken along for the ride may create conflicts or ...

Understanding the classical model for linking: You can override an LIB with another LIB, and a LIB with an OBJ, but you can’t override an OBJ

If you study the classical model for linking, you'll see that OBJ files provided directly to the linker have a special property: They are added to the module even if nobody requests a symbol from them. OBJs bundled into a library are pulled into the module only if they are needed to resolve a needed symbol request. If nobody needs a symbol ...