I'm trying to add register an exe file with a file extension. The code below works fine with XP, but throws an error in Win Vista/7.
var
reg: TRegistry;
begin
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CLASSES_ROOT;
reg.OpenKey('.' + ExtName, True);
reg.WriteString('', ExtName + 'file'); //error: Failed to set data for ''
reg.CloseKey;
reg.CreateKey(ExtName + 'file');
reg.OpenKey(ExtName + 'file\DefaultIcon', True);
reg.WriteString('', AppName + ',0');
reg.CloseKey;
reg.OpenKey(ExtName + 'file\shell\open\command', True);
reg.WriteString('', AppName + ' "%1"');
reg.CloseKey;
finally
reg.Free;
end;
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
How can I accomplish this same thing in Vista/7?