Thursday, December 20, 2012

BASICish C#

Below is the C# code.

public static IEnumerable<T> AsEnumerable<T>(this System.Collections.IList source)
{
    return from object item in source select (T)item;
}
Doesn't it smell Basicish?

Thursday, September 13, 2012

IMediaExtension::SetProperties(IPropertySet*) in WinRT/C++

Media foundation transform (MFT) is initialized via
// IMediaExtension
SetProperties(STDMETHODIMP SetProperties(ABI::Windows::Foundation::Collections::IPropertySet *pConfiguration);
To get values from pConfiguration:
1. Convert it to IMap<HSTRING, IInspectable*> interface.
2. The value of each KeyValuePair is also IInspectable. To get the actual value of it - unbox it by converting value to IReference<T>. For strings this approach doesn't work: the documentation states "T must not be a delegate type or an HSTRING". So the IReference<HSTRING> is not possible. The workaround is to convert the value to IPropertyValue<T> and then chat with it to get actual value. Below is a helper method which implements it.

Saturday, September 1, 2012

Windows 8 x64 driver installation error - signature test fails

When you install the driver for Hitron BRG 35302 cable modem on Windows 8 x64, you get an error message "The hash for the file is not present in the specified catalog file. The file is likely corrupt or the victim of tampering". Then the installation process stops.

To solve it, turn the Windows 8 checking of the driver's signature off.