You need to specify that the thread be a single threaded apartment. You do that by calling SetApartmentState(System.Threading.ApartmentState.STA)
before the thread starts. Note that you should not call CoInitialize
or CoInitializeEx
since that will be done automatically for you. More details on that can be found at this excellent question: Do i need to call CoInitialize before interacting with COM in .NET?
The other point to make is that SHGetFileInfo
is not threadsafe. If you have multiple threads that call SHGetFileInfo
then you will need to serialize those calls to SHGetFileInfo
.