简体   繁体   English

确定扩展的注册申请

[英]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.

相关问题 使用带有更改扩展名的sqlite db文件作为注册的应用程序文件是个坏主意吗? - Is using sqlite db file with changed extension as registered application file a bad idea? 在应用程序中注册的扩展名列表 - List of extensions registered with an application 启动注册的mime助手应用程序 - Launching a registered mime helper application 如何确定在Delphi XE2中注册的OCX的版本号 - How to determine the version number of a registered OCX in Delphi XE2 在应用程序级别之外注册为allowDefinition ='MachineToApplication'的部分 - section registered as allowDefinition='MachineToApplication' beyond application level Qt Widget应用程序“未注册库”错误 - Qt Widget Application “Library not registered” error 如何确定该应用程序是否是MFC程序? - How to determine if the application is an MFC program? 如何将图标与自定义应用程序关联(已注册Powershell脚本) - How to associate icon with custom application(registered with a powershell script) 如何一次将多个文件传递给我的注册应用程序? - How to pass several files at once to my registered application? 将文件扩展名与 Java 应用程序关联 - Associate File Extension with Java Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM