Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to get IApplicationAssociationRegistration::QueryAppIsDefault working
    primarykey
    data
    text
    <p>So I'm trying to use <a href="http://msdn.microsoft.com/en-us/library/bb776332%28VS.85%29.aspx" rel="nofollow noreferrer">IApplicationAssociationRegistration</a>, which has been introduced with Windows Vista. I am using Windows 7 x64.</p> <p>However, every call that receives a ProgId (aka AppRegistryName, e.g. "FirefoxHTML") returns a HRESULT of 0x80070002 which means "The system cannot find the file specified". Calls like QueryCurrentDefault that do not need/receive a ProgId, but instead return one, work flawlessly. I'm at a complete loss of what kind of file is not being found here and I'm also out of ideas what else might be going on.</p> <p>Since I'm not really into COM stuff, it may be something super stupid that I am missing here. Thanks for any advice!</p> <p>Here's a screenshot: <a href="https://i.imgur.com/x62y3.png" rel="nofollow noreferrer">http://i.imgur.com/x62y3.png</a></p> <p>And here's the crude isolated code for you guys to try/reproduce, don't forget to set a breakpoint:</p> <pre><code>#include &lt;windows.h&gt; #include &lt;tchar.h&gt; #include &lt;shobjidl.h&gt; HRESULT CheckStuff(__out BOOL* pfHasDotHTM) { IApplicationAssociationRegistration* pAAR; HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), (void**)&amp;pAAR); if (SUCCEEDED(hr)) { hr = pAAR-&gt;QueryAppIsDefault(L".html", AT_FILEEXTENSION, AL_EFFECTIVE, L"FirefoxHTML", pfHasDotHTM); pAAR-&gt;Release(); } return hr; } int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { CoInitializeEx(NULL, COINIT_MULTITHREADED); BOOL bx = FALSE; CheckStuff(&amp;bx); CoUninitialize(); return 0; } </code></pre> <hr> <p><strong>Update 2:</strong></p> <p>Got it!</p> <p>The key is that using the ProgId as AppRegistryName is plain wrong. One needs to use the name registered in HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications!</p> <p>Working example:</p> <pre><code> hr = pAAR-&gt;QueryAppIsDefault(L".html", AT_FILEEXTENSION, AL_EFFECTIVE, L"Firefox", pfHasDotHTM); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload