Delphi - How to change default file extensions in Vista/Win 7
delphi
Solution
Have you tried running this as an admin? You cannot write to HKEY_CLASSES_ROOT as any old user in Vista. You can't in XP, either, unless you are running as a power user/admin. Which many developers are, but that's besides the point.
In other words, you'll need elevation to do this. Here is a good link on how to setup a manifest to mark your application with this characteristic.
Problem
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?