8 hours ago
(This post was last modified: 8 hours ago by Gary Beene.)
Howdy, Stuart!
Thanks for the reply! There may be more to it.
I have PCs which do not have 365 installed and they can run the Everything preview (which uses IPreviewHandler) just fine.
The include file shobjidl.inc is present in Jose's include files and contains content about IParentHandler. David passed on this code for me to look at.
Is that information inconsistent with Google AI? It may be because I see some SHELLEX commands, but I really don't know squat about the language.
Thanks for the reply! There may be more to it.
I have PCs which do not have 365 installed and they can run the Everything preview (which uses IPreviewHandler) just fine.
The include file shobjidl.inc is present in Jose's include files and contains content about IParentHandler. David passed on this code for me to look at.
Is that information inconsistent with Google AI? It may be because I see some SHELLEX commands, but I really don't know squat about the language.
Code:
// Given extension, determine the CLSID of its handler
static int _ui_preview_CLSID_from_filename(const utf8_t *filename,int is_folder,CLSID *clsid)
{
int ret;
utf8_buf_t data_cbuf;
utf8_buf_t key_cbuf;
ret = 0;
utf8_buf_init(&data_cbuf);
utf8_buf_init(&key_cbuf);
// CONFIG_PREVIEW_HANDLERS
if (!ret)
{
if (_ui_preview_get_config_preview_handler(is_folder,filename,clsid))
{
debug_printf("got preview handler from config\n");
ret = 1;
}
}
if (is_folder)
{
if (!ret)
{
utf8_buf_printf(&key_cbuf,"%s\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}","Folder");
if (_ui_preview_CLSID_from_key(key_cbuf.buf,clsid))
{
ret = 1;
}
}
}
else
{
utf8_buf_t perceived_type_cbuf;
const utf8_t *extension_with_dot;
int got_perceived_type;
utf8_buf_init(&perceived_type_cbuf);
got_perceived_type = 0;
extension_with_dot = utf8_string_get_extension_including_dot(filename);
// if there's no extension, use "." like Windows Explorer.
if (!*extension_with_dot)
{
extension_with_dot = (const utf8_t *)".";
}
// try EverythingSystemFileAssociations
/*
if (!ret)
{
utf8_buf_printf(&key_cbuf,"EverythingSystemFileAssociations\\%s\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}",extension_with_dot);
if (os_registry_get_string(HKEY_CLASSES_ROOT,key_cbuf.buf,0,&data_cbuf))
{
if (os_CLSIDFromString(data_cbuf.buf,clsid))
{
//debug_printf("got preview handler {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",clsid->Data1,clsid->Data2,clsid->Data3,clsid->Data4[0],clsid->Data4[1],clsid->Data4[2],clsid->Data4[3],clsid->Data4[4],clsid->Data4[5],clsid->Data4[6],clsid->Data4[7]) ;
debug_printf("got preview handler from esfa\n");
ret = 1;
}
}
}
*/
// try ext
if (!ret)
{
utf8_buf_printf(&key_cbuf,"%s\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}",extension_with_dot);
if (_ui_preview_CLSID_from_key(key_cbuf.buf,clsid))
{
ret = 1;
}
}
// try class first (like Windows Explorer)
if (!ret)
{
if (os_registry_get_string(HKEY_CLASSES_ROOT,extension_with_dot,0,&data_cbuf))
{
if (*data_cbuf.buf)
{
utf8_buf_printf(&key_cbuf,"%s\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}",data_cbuf.buf);
if (_ui_preview_CLSID_from_key(key_cbuf.buf,clsid))
{
ret = 1;
}
}
}
}
// try SystemFileAssociations
if (!ret)
{
utf8_buf_printf(&key_cbuf,"SystemFileAssociations\\%s\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}",extension_with_dot);
if (_ui_preview_CLSID_from_key(key_cbuf.buf,clsid))
{
ret = 1;
}
}
// same as Windows Explorer, try *
// after SystemFileAssociations\.extension
if (!ret)
{
utf8_buf_printf(&key_cbuf,"%s\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}","*");
if (_ui_preview_CLSID_from_key(key_cbuf.buf,clsid))
{
ret = 1;
}
}
// like Windows Explorer, check PerceivedType for text and use the builtin txt preview handler CLSID.
if (!ret)
{
if (os_registry_get_string(HKEY_CLASSES_ROOT,extension_with_dot,(const utf8_t *)"PerceivedType",&perceived_type_cbuf))
{
got_perceived_type = 1;
if (_ui_preview_CLSID_from_perceived_type(perceived_type_cbuf.buf,clsid))
{
ret = 1;
}
}
}
// like Windows Explorer, check PerceivedType for text in SystemFileAssociations.
if (!ret)
{
// same as:
// Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.log
utf8_buf_printf(&key_cbuf,"SystemFileAssociations\\%s",extension_with_dot);
if (os_registry_get_string(HKEY_CLASSES_ROOT,key_cbuf.buf,(const utf8_t *)"PerceivedType",&perceived_type_cbuf))
{
got_perceived_type = 1;
if (_ui_preview_CLSID_from_perceived_type(perceived_type_cbuf.buf,clsid))
{
ret = 1;
}
}
}
// try our text/plain extensions.
if (!ret)
{
if (file_content_is_text_plain_extension(extension_with_dot))
{
got_perceived_type = 1;
if (_ui_preview_CLSID_from_perceived_type("text",clsid))
{
ret = 1;
}
}
}
if (!ret)
{
if (!got_perceived_type)
{
utf8_buf_printf(&key_cbuf,"%s\\ShellEx\\{8895b1c6-b41f-4c1c-a562-0d564250836f}","Unknown");
if (_ui_preview_CLSID_from_key(key_cbuf.buf,clsid))
{
ret = 1;
}
}
}
utf8_buf_kill(&perceived_type_cbuf);
}
utf8_buf_kill(&key_cbuf);
utf8_buf_kill(&data_cbuf);
return ret;
}
static _ui_preview_IPreviewHandler_t *_ui_preview_handler_create_instance(CLSID *clsid)
{
_ui_preview_IPreviewHandler_t *ret;
_ui_preview_IPreviewHandler_t *preview_handler;
HRESULT hres;
ret = NULL;
// MUST be CLSCTX_LOCAL_SERVER for IID_IPreviewHandler
// we can use CoCreateInstance to create multiple instances.
// Its slower than CoGetClassObject, but we dont care about performance here.
hres = CoCreateInstance(clsid,NULL,CLSCTX_LOCAL_SERVER,&_ui_preview_IID_IPreviewHandler,(LPVOID*)&preview_handler);
if (SUCCEEDED(hres))
{
ret = preview_handler;
}
else
{
debug_error_printf("CoCreateInstance %08x\n",hres);
}
return ret;
}