How to associate a program with a file type, but only for the current user?

If you want to register the association for every user, write your data to HKEY_LOCAL_MACHINE\Software\Classes If you want to register the association for the current user only, write your data to HKEY_CURRENT_USER\Software\Classes This is how to do the latter: with TRegistry.Create do try RootKey := HKEY_CURRENT_USER; if OpenKey(‘\Software\Classes\.myfile’, true) then WriteString(”, ‘MyAppDataFile’); if OpenKey(‘\Software\Classes\MyAppDataFile’, true) … Read more

Where does Windows store its “Open With” settings?

Take a look in: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\ and the sub-key of that is the extension you reassigned. Under that there will be the UserChoice and OpenWithList sub-keys which will contain your redefinition. You may also want to read http://support.microsoft.com/kb/950505 which talks about your issue. Update As of Windows 8, life has gotten far more complicated. To create … Read more

How to associate application with existing file types using WiX installer?

Here’s a full, complete example with a bit more detail and cleaner code than in the linked question and should provide a better answer. Quite timely as I’ve recently finished porting the code posted previously, to use proper ProgId elements so this is fresh in my mind 😉 In regards to the ‘what here’, you … Read more

Registering a COM without Admin rights

For what it’s worth, I’ve written a set of C# utilities that register/unregister a .NET type (should be marked as ComVisible of course) in user’s registry without requiring regasm, nor UAC prompts, you can use it like this: // register into current user registry, needs no specific rights ComUtilities.RegisterComObject(ComUtilities.Target.User, typeof(MyClass)); // unregister from user registry, … Read more

modifying the registry key value

It’s been a while I did reg hacks, but something like this could work: RegistryKey myKey = Registry.LocalMachine.OpenSubKey(“SOFTWARE\\Company\\Compfolder”, true); if(myKey != null) { myKey.SetValue(“Deno”, “1”, RegistryValueKind.String); myKey.Close(); }

Registry Watcher C#

WMI can sometimes be interesting to work with…I think I understand your question, so take a look at the code snippet below and let me know if it’s what you’re looking for. // ——————————————————————————————————————— // <copyright file=”Program.cs” company=””> // // </copyright> // <summary> // Defines the WmiChangeEventTester type. // </summary> // ——————————————————————————————————————— namespace WmiExample { … Read more

How to open a WOW64 registry key from a 64-bit .NET application

If you can change the target .Net version to v4, then you can use the new OpenBaseKey function e.g. RegistryKey registryKey; if (Environment.Is64BitOperatingSystem == true) { registryKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64); } else { registryKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32); }

Command line to remove an environment variable from the OS level configuration

To remove the variable from the current environment (not permanently): set FOOBAR= To permanently remove the variable from the user environment (which is the default place setx puts it): REG delete HKCU\Environment /F /V FOOBAR If the variable is set in the system environment (e.g. if you originally set it with setx /M), as an … Read more