如何查找文档是否可以通过ShellExecute打开? [英] How to find if an document can be OPENed via ShellExecute?

查看:225
本文介绍了如何查找文档是否可以通过ShellExecute打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查一个特定文件是否可以通过ShellExecute成功地打开,所以我试图使用AssocQueryString来发现这一点。

I want to check if a particular file can be successfully "OPEN"ed via ShellExecute, so I'm attempting to use AssocQueryString to discover this.

示例:

DWORD size = 1024;
TCHAR buff[1024];  // fixed size as dirty hack for testing

int err = AssocQueryString(0, ASSOCSTR_EXECUTABLE, ".mxf", NULL ,buff , &size);
openAction->Enabled  = ((err == S_OK) || (err == S_FALSE)) && (size > 0);

现在,几乎如果有注册的应用程序,我得到字符串。

Now, this almost works. If there's a registered application, I get the string.

但是,有一个catch:在Vista上,即使没有注册的应用程序,它返回应用程序c: \Windows \System32\shell32.dll是相关联的,这是引起100%无用的东西Windows无法打开此文件:使用Web服务找到正确的程序?对话。

But, there's a catch: On Vista, even if there is no registered application, It returns that the app c:\Windows\System32\shell32.dll is associated, which is the thing that brings up the 100% useless "Windows cannot open this file: Use the Web service to find the correct program?" dialog.

显然,我想隐藏最终用户的crice的peice,但只是将返回的字符串与一个常量比较,看起来像一个丑陋的,暴力的和脆弱的方式

Obviously I want to hide that peice of cr*p from end users, but simply comparing the returned string to a constant seems like an ugly, brute-force and fragile way of doing it.

此外,黑客注册表完全禁用此对话框不是一个好主意。

Also, hacking the registry to totally disable this dialog isn't a great idea.

推荐答案

我总是使用 FindExecutable() 获取给定文档的注册申请。

I always use FindExecutable() to get the registered application for a given document.

这篇关于如何查找文档是否可以通过ShellExecute打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆