-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetHandler<IStream> hangs after getting property from ShellItem #49
Comments
I'm wondering if this has to do with using the same IBindCtxt twice. Does it hang if you call GetHandler and then get the property? |
I liked the idea of a COM IStream wrapper so I did some searching for IStreamStream but couldn't find an implementation, so I wrote my own. You'll find it in the next release as Vanara.InteropServices.ComStream. I answered the last question I sent. No, it only happens in the order you mentioned. I'm recreating your code in native C++ to see if the problem is there too. I'll let you know my findings. |
Well, I ran the following code and it works just fine so the problem is somewhere deep in my library. I'll keep looking for the problem. HRESULT hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
IShellItem2* pshi2;
hr = SHCreateItemFromParsingName(L"C:\\Temp\\Holes.mp4", NULL, IID_PPV_ARGS(&pshi2));
if (SUCCEEDED(hr))
{
PROPVARIANT pv = { 0 };
hr = pshi2->GetProperty(PKEY_MIMEType, &pv);
PropVariantClear(&pv);
LPBC ppbc;
hr = CreateBindCtx(0, &ppbc);
if (SUCCEEDED(hr))
{
IStream* pstream;
hr = pshi2->BindToHandler(ppbc, BHID_Stream, IID_PPV_ARGS(&pstream));
if (SUCCEEDED(hr))
pstream->Release();
ppbc->Release();
}
pshi2->Release();
}
CoUninitialize();
} |
It works fine calling GetHandler before the property. |
Found the problem: It turns out that if you call As a work around (though a little hacky) you can use the methods on if (!shellItem.IsFolder)
Console.WriteLine(((IShellItem2)shellItem.IShellItem).GetString(PROPERTYKEY.System.MIMEType)); Besides |
…t holding onto the IPropertyStore interface so as to prevent a lock condition on the ShellItem (#49). So I had to change some of the protected methods to support the change.
It wasn't so hard a change after all. I have it working in the posted version of the library. I will release later this week after further testing. |
Package 2.3.8 with the changes has been published. |
After getting a ShellItem for a file, I get the MIMEType property followed by opening the file using GetHandler. The app hangs on the call to GetHandler
If I new a ShellItem (from a PIDL) for the properties call and new another ShellItem for the GetHandler it works fine
What code is involved
Calling ShellItem.GetHandler after ShellItem.Properties.TryGetValue
Expected behavior
GetHandler should return an IStream
The text was updated successfully, but these errors were encountered: