Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, all
I was trying to change some registry key values in my C++ project on win7. one of them is HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.url\UserChoice
and what I want to change is the "Progid"'s value.
Here is the funny thing:
when I firt run my pogram, the key can be changed correctly. After that, I run IE and set it as the default browser. When I try to run my program a second time, it fails, the key above cannot be changed. I try to change it manually in regedit.exe, an error "error editing values" showes up.
So I wonder, does IE lock the key up so I cann't change it? If it's , how can I unlock it in my C++ program? Is there any API I can use?
Any answers from you will be appreciated.
Thanks.
Posted

1 solution

I think you want to do the file association. Set IE as a default browser to open a .url file.

For Vista and Windows 7 use SetAppAsDefault.
[^]
HRESULT hr = S_OK;
	
	CoInitialize(NULL); 

	IApplicationAssociationRegistration* pAAR;
	ASSOCIATIONTYPE AsType;
	AsType = AT_URLPROTOCOL;
	
	hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
		NULL,
		CLSCTX_INPROC,
		__uuidof(IApplicationAssociationRegistration),
		(void**)&pAAR);
	
	if (SUCCEEDED(hr))
    {
		hr = pAAR->SetAppAsDefault(lpszRegisteredApp,
                                   _T(".url"),
                                   AsType);

    }
	pAAR->Release();
	pAAR = NULL;
	CoUninitialize(); 
	
	return hr;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900