Hello,

i was wondering how you would create a file association in c++ with the registry, in lua it would be something like this...

function File.SetAssociation(Ext, Exe, Icon, Long)
	local cKey = Long;
	Registry.SetValue(HKEY_CLASSES_ROOT, Ext, "", Key);
	Registry.SetValue(HKEY_CLASSES_ROOT, Key, "", Long);
	Registry.SetValue(HKEY_CLASSES_ROOT, Key.."\\DefaultIcon","",Icon..",0");
	Registry.SetValue(HKEY_CLASSES_ROOT, Key.."\\shell\\open\\command", "", "\""..Exe.."\" \"%1\"");
end

how would this be done in c++ and thanks for your time, it means alot to me.

Kind Regards,
Nathaniel Blackburn

Recommended Answers

You can do it in the Win32 API, search at google and I'm sure you'll find some examples.
Another way, if you are running Windows, is to make a new reg file, and then import it using system calls, example:

ofstream regFile("temp.reg");
if(!regFile)
    cerr << "Can't open …
Jump to Post

All 2 Replies

You can do it in the Win32 API, search at google and I'm sure you'll find some examples.
Another way, if you are running Windows, is to make a new reg file, and then import it using system calls, example:

ofstream regFile("temp.reg");
if(!regFile)
    cerr << "Can't open file" << endl;
else
{
/* Write to the registry file here */
regFile.close();
system("reg import temp.reg");
/* You can then remove this reg file if you want */
}

Thanks for your help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.