Would this be better? It avoids repetitive if and return statements.
PCWSTR WINAPI VariantToStringWithDefault(const VARIANT *pvar, LPCWSTR pszDefault) { PCWSTR ret = pszDefault;
TRACE("(%p, %s)\n", pvar, debugstr_w(pszDefault));
switch(V_VT(pvar)) { case VT_BSTR: ret = V_BSTR(pvar); break; case VT_BYREF | VT_BSTR: ret = *V_BSTRREF(pvar); break; case VT_BYREF | VT_VARIANT: { if (V_VT(V_VARIANTREF(pvar)) == VT_BSTR) { ret = V_BSTR(V_VARIANTREF(pvar); break; } if (V_VT(V_VARIANTREF(pvar)) == (VT_BYREF | VT_BSTR)) { ret = *V_BSTRREF(V_VARIANTREF(pvar)); break; } } }
if (ret == NULL) return L"";
return ret; } -- Kind regards, Mohamad