Hey, where did my comment go? Typing it again:

Maybe instead of explicitly checking for `IUnknown`, simply check the result of cast to Object?
```D
Object o = cast(Object)val;
if (o is null)
    formatValue(w, *cast(void**)&val, f);
else
    formatValue(w, o, f);
```
If I'm not mistaken, you get the correct result, but also:
1. Avoids windows specific code.
2. Avoids an extra import.
3. Should be more robust w.r.t. potential "extern(C++) interfaces" that also could potentially not be castable to object.