How can I find the upgrade code for an installed application in C#?

I have discovered the upgrade codes are stored in the following registry location. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes The registry key name is the upgrade code and the registry key value name is the product code. I can easily extract these values however the codes are stored in a different format. The red circle shows the formatted upgrade code, … Read more

What registry access can you get without Administrator privileges?

In general, a non-administrator user has this access to the registry: Read/Write to: HKEY_CURRENT_USER Read Only: HKEY_LOCAL_MACHINE HKEY_CLASSES_ROOT (which is just a link to HKEY_LOCAL_MACHINE\Software\Classes) It is possible to change some of these permissions on a key-by-key basis, but it’s extremely rare. You should not have to worry about that. For your purposes, your application … Read more

IE Enable/Disable Proxy Settings via Registry

The problem is that IE won’t reset the proxy settings until it either closes, or has its configuration refreshed. Below is the code that I’ve used to get this working: function Refresh-System { $signature = @’ [DllImport(“wininet.dll”, SetLastError = true, CharSet=CharSet.Auto)] public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength); ‘@ $INTERNET_OPTION_SETTINGS_CHANGED … Read more

Read and write from/to registry in VBA

I think the problem here was that the macro did not have permission to write to the registry. More information in this page. I could read the key’s value using the WScript object just fine: Debug.Print CreateObject(“WScript.Shell”).RegRead(“HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR\Start”) To write (it should work if you have permissions): CreateObject(“WScript.Shell”).RegWrite “HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR\Start”, 4, “REG_DWORD” How I got it to … Read more

How to determine Windows Java installation location

You can do it through the registry. You were looking in the wrong place though. I knocked together a quick example for you: private string GetJavaInstallationPath() { string environmentPath = Environment.GetEnvironmentVariable(“JAVA_HOME”); if (!string.IsNullOrEmpty(environmentPath)) { return environmentPath; } string javaKey = “SOFTWARE\\JavaSoft\\Java Runtime Environment\\”; using (Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(javaKey)) { string currentVersion = rk.GetValue(“CurrentVersion”).ToString(); using (Microsoft.Win32.RegistryKey … Read more

Read a Registry Key

Reading the registry is pretty straightforward. The Microsoft.Win32 namespace has a Registry static class. To read a key from the HKLM node, the code is: RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(“Software\\NodeName”) If the node is HKCU, you can replace LocalMachine with CurrentUser. Once you have the RegistryKey object, use GetValue to get the value from the registry. … Read more

Registry vs. INI file for storing user configurable application settings [closed]

Pros of config file: Easy to do. Don’t need to know any Windows API calls. You just need to know the file I/O interface of your programming language. Portable. If you port your application to another OS, you don’t need to change your settings format. User-editable. The user can edit the config file outside of … Read more

How to check if a registry value exists using C#?

For Registry Key you can check if it is null after getting it. It will be, if it doesn’t exist. For Registry Value you can get names of Values for the current key and check if this array contains the needed Value name. Example: public static bool checkMachineType() { RegistryKey winLogonKey = Registry.LocalMachine.OpenSubKey(@”System\CurrentControlSet\services\pcmcia”, true); return … Read more