Hi I have been writing this piece of code which will search for all the possible video capture devices on the machine using the Windows DirectShow API. But no matter what I do I can't get this block of code to return the list of devices in a suitable format back to my VB.NET code. I keep getting the error pInvoke Restriction:Can't return a variant. Is there away to convert possibly the variant to a char array, and return the array back to the vb.NET GUI? The code I have is as follows :
extern "C" __declspec(dllexport) VARIANT __cdecl getDevice()
{
// Create the System Device Enumerator.
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
reinterpret_cast<void**>(&pDevEnum));
if (SUCCEEDED(hr))
{
// Create an enumerator for the video capture category.
hr = pDevEnum->CreateClassEnumerator(
CLSID\_VideoInputDeviceCategory,
&pEnum, 0);
}
while (pEnum->Next(1, &pMoniker, NULL) == S\_OK)
{
IPropertyBag \*pPropBag;
hr = pMoniker->BindToStorage(0, 0, IID\_IPropertyBag,
(void\*\*)(&pPropBag));
if (FAILED(hr))
{
pMoniker->Release();
continue; // Skip this one, maybe the next one will work.
}
// Find the description or friendly name.
extern VARIANT varName;
VariantInit(&varName);
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
pPropBag->Release();
pMoniker->Release();
}
return varName;
}
Any feedback would be greatly appreciated Cheers Boyindie