I have a small program which I use when I have to restore some file association silently modified by a new program installed. For instance I have recently installed VideoPad and it has associated many video files with itself without prompting for this. The code (working perfectly some time ago) is something like:
Extension := '.avi';
Prog := 'C:\Program files\VideoLAN\VLC\vlc.exe';
procedure writeAssociation(Extension, Prog: string);
Log := '';
reg := TRegistry.Create;
reg.RootKey := HKEY_CLASSES_ROOT;
reg.LazyWrite := false;
reg.OpenKey(Extension + '\shell\open\command', true);
reg.WriteString('', Prog + ' %1');
reg.OpenKey(Extension + '\DefaultIcon', true);
reg.WriteString('', Prog + ',0');
Log := 'File type ' + Extension + ' is now associated with ' + Prog;
Log := 'Association failed for file type ' + Extension;
Now this code changes the registry values correctly, but avi files are still opened by VideoPad when I double-click on them and the icon is not vlc icon but VideoPad one.
Now, my problem is not to reassociate the avi extension with vlc: I can do it manually. My problem is how to write a program which set the files associations in the registry and makes these associations be respected by Windows. That is, I have to understand why the registry values set by my code above are ignored by Windows.
Hope to have been clear.
Thanks in advance for any advice.