Using Visual Studio 2015 RC and the Windows SDK 7.1 with this simple DirectShow code (C++ with COM)
#include <dshow.h>
#include <iostream>
int main ()
{
CoInitialize(nullptr);
ICreateDevEnum* devEnum = nullptr;
CoCreateInstance(
CLSID_SystemClock,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum,
reinterpret_cast<void**>(devEnum)
);
IEnumMoniker* monikerEnum = nullptr;
devEnum->CreateClassEnumerator(
CLSID_VideoInputDeviceCategory,
&monikerEnum,
0
);
IMoniker* moniker = nullptr;
ULONG fetchedCount = 0;
while (monikerEnum->Next(1, &moniker, &fetchedCount))
{
IPropertyBag* propBag = nullptr;
moniker->BindToStorage(0, 0, IID_IPropertyBag, reinterpret_cast<void**>(propBag));
VARIANT var;
VariantInit(&var);
propBag->Read(L"FriendlyName", &var, nullptr);
std::cout << var.bStrVal;
VariantClear(&var);
}
}
leads to:
error C2039: 'bStrVal': is not a member of 'tagVARIANT'
The tagVARIANT
structure is defined as:
typedef /* [wire_marshal] */ struct tagVARIANT VARIANT;
struct tagVARIANT
{
union
{
struct __tagVARIANT
{
VARTYPE vt;
WORD wReserved1;
WORD wReserved2;
WORD wReserved3;
union
{
LONGLONG llVal;
LONG lVal;
BYTE bVal;
SHORT iVal;
FLOAT fltVal;
DOUBLE dblVal;
VARIANT_BOOL boolVal;
_VARIANT_BOOL bool;
SCODE scode;
CY cyVal;
DATE date;
BSTR bstrVal;
IUnknown *punkVal;
IDispatch *pdispVal;
SAFEARRAY *parray;
BYTE *pbVal;
SHORT *piVal;
LONG *plVal;
LONGLONG *pllVal;
FLOAT *pfltVal;
DOUBLE *pdblVal;
VARIANT_BOOL *pboolVal;
_VARIANT_BOOL *pbool;
SCODE *pscode;
CY *pcyVal;
DATE *pdate;
BSTR *pbstrVal;
IUnknown **ppunkVal;
IDispatch **ppdispVal;
SAFEARRAY **pparray;
VARIANT *pvarVal;
PVOID byref;
CHAR cVal;
USHORT uiVal;
ULONG ulVal;
ULONGLONG ullVal;
INT intVal;
UINT uintVal;
DECIMAL *pdecVal;
CHAR *pcVal;
USHORT *puiVal;
ULONG *pulVal;
ULONGLONG *pullVal;
INT *pintVal;
UINT *puintVal;
struct __tagBRECORD
{
PVOID pvRecord;
IRecordInfo *pRecInfo;
} __VARIANT_NAME_4;
} __VARIANT_NAME_3;
} __VARIANT_NAME_2;
DECIMAL decVal;
} __VARIANT_NAME_1;
} ;
So the member exists in the VARIANT structure. Why I'm not able to compile the code?
It seems just a capitalization problem, between
bStrVal
(in the code) andbstrVal
(in the structure definition). Note that theS
is different. C and C++ are case-sensitive languages.