-
Notifications
You must be signed in to change notification settings - Fork 2
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
Suggestion on detection of text files #272
Comments
You're right, that code is very fragile. I do want to have the option to override the text editor with a different preview handler in some circumstances. For example, if a The windows TXT previewer is registered as the default handler for all perceived Text files which don't have some other handler installed (under And eventually I'm hoping to add configurable file type associations (#155), since neither preview handler associations nor perceived types are easily user-editable. So once I add that, maybe it will be less of an issue to show the text editor for all Text files. By the way, thank you for your blog post on hosting preview handlers, it was very helpful for this project as you can see! |
To query the Windows text preview handler CLSID robustly, we can do this: ASSOCIATIONELEMENT perceivedText[1] { { ASSOCCLASS_SYSTEM_STR, nullptr, L"text" } };
IQueryAssociations *pqa;
AssocCreateForClasses(perceivedText, 1, IID_IQueryAssociations, (void **)&pqa);
// Use pqa->GetString to obtain the preview handler CLSID for perceived type "text". For checking whether Windows is falling back to that handler (the user might have set the handler for a specific type to the Windows text preview handler, even if that type is already perceived as |
On src/CreateItemWindow.cpp#L45, the detection is done by comparing the preview handler CLSID with the current Windows text preview handler CLSID. This is not robust as the next version of Windows could use a different CLSID for text preview, and other software might override the text preview handler with its own CLSID.
From the business logic, the purpose of detecting this Windows text preview handler is to provide editor functionality for text files. The suggested way to test whether a file is text file is to query its perceived type using
AssocGetPerceivedType
function and check whether the perceived type is the predefined enumeration valuePERCEIVED_TYPE_TEXT
.The text was updated successfully, but these errors were encountered: