[英]Determine the registered application for an extension
I've got a file extension and I'd like to get the name of the application (if there is one) that will be invoked when I ShellExecute a file of that type. 我有一个文件扩展名,我想获取当我ShellExecute此类文件时将调用的应用程序的名称(如果有)。 This is a WTL/C++ app.
这是一个WTL / C ++应用程序。 Is there any sample code out there that does this?
是否有任何示例代码可以做到这一点?
Thanks! 谢谢!
twk, TWK,
You're probably looking for the Win32 AssocQueryStringByKey Function. 您可能正在寻找Win32 AssocQueryStringByKey函数。
http://msdn.microsoft.com/en-us/library/bb773473(VS.85).aspx http://msdn.microsoft.com/en-us/library/bb773473(VS.85).aspx
The ASSOCSTR value that specifies the type of string that is to be returned: ASSOCSTR值,该值指定要返回的字符串类型:
typedef enum {
ASSOCSTR_COMMAND = 1,
ASSOCSTR_EXECUTABLE,
ASSOCSTR_FRIENDLYDOCNAME,
ASSOCSTR_FRIENDLYAPPNAME,
ASSOCSTR_NOOPEN,
ASSOCSTR_SHELLNEWVALUE,
ASSOCSTR_DDECOMMAND,
ASSOCSTR_DDEIFEXEC,
ASSOCSTR_DDEAPPLICATION,
ASSOCSTR_DDETOPIC,
ASSOCSTR_INFOTIP,
ASSOCSTR_QUICKTIP,
ASSOCSTR_TILEINFO,
ASSOCSTR_CONTENTTYPE,
ASSOCSTR_DEFAULTICON,
ASSOCSTR_SHELLEXTENSION,
ASSOCSTR_DROPTARGET,
ASSOCSTR_DELEGATEEXECUTE,
ASSOCSTR_MAX
} ASSOCSTR;
My guess is that you want ASSOCSTR_FRIENDLYAPPNAME. 我的猜测是您想要ASSOCSTR_FRIENDLYAPPNAME。
DWORD dwSize = 255;
TCHAR sBuffer[MAX_PATH] = {0};
HRESULT hr = AssocQueryString(0, ASSOCSTR_EXECUTABLE, _T(".htm"), _T("Open"), sBuffer, &dwSize);
CString csExt;
csExt.Format(_T("%s"), sBuffer);
AfxMessageBox(csExt);
Sorry, no code, but some useful information. 抱歉,没有代码,但是有一些有用的信息。 See this related question: how-does-vista-generate-the-icon-for-documents-associated-to-my-application
参见以下相关问题: vista如何生成与我的应用程序相关的文档的图标
It asked about icons, but it turns out the program associated to an extension is stored in the same place in the registry as the icon for that extension. 它询问了有关图标的信息,但事实证明与扩展名关联的程序与该扩展名的图标存储在注册表的同一位置。
自1995年以来就是Win32常见问题解答(Shell,请参见Google网上论坛,Win32)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.