0

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

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by shadowscape
0

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 */
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.