How to read a value from the Windows registry

Here is some pseudo-code to retrieve the following: If a registry key exists What the default value is for that registry key What a string value is What a DWORD value is Example code: Include the library dependency: Advapi32.lib HKEY hKey; LONG lRes = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L”SOFTWARE\\Perl”, 0, KEY_READ, &hKey); bool bExistsAndSuccess (lRes == ERROR_SUCCESS); bool … Read more

Java Error opening registry key

Make sure you remove any java.exe, javaw.exe and javaws.exe from your Windows\System32 folder and if you have an x64 system (Win 7 64 bits) also do the same under Windows\SysWOW64. If you can’t find them at these locations, try deleting them from C:\ProgramData\Oracle\Java\javapath.

How to run a C# application at Windows startup?

Code is here (Win form app): using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.Win32; namespace RunAtStartup { public partial class frmStartup : Form { // The path to the key where Windows looks for startup applications RegistryKey rkApp = Registry.CurrentUser.OpenSubKey(“SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run”, true); public frmStartup() { InitializeComponent(); // Check … Read more

Requested registry access is not allowed

app.manifest should be like this: <?xml version=”1.0″ encoding=”utf-8″?> <asmv1:assembly manifestVersion=”1.0″ xmlns=”urn:schemas-microsoft-com:asm.v1″ xmlns:asmv1=”urn:schemas-microsoft-com:asm.v1″ xmlns:asmv2=”urn:schemas-microsoft-com:asm.v2″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”> <assemblyIdentity version=”1.0.0.0″ name=”MyApplication.app” /> <trustInfo xmlns=”urn:schemas-microsoft-com:asm.v2″> <security> <requestedPrivileges xmlns=”urn:schemas-microsoft-com:asm.v3″> <requestedExecutionLevel level=”requireAdministrator” uiAccess=”false” /> </requestedPrivileges> </security> </trustInfo> </asmv1:assembly>

Windows is not passing command line arguments to Python programs executed from the shell

I think I solved this. For some reason there is a SECOND place in the registry (besides that shown by the file associations stored in HKEY_CLASSES_ROOT\Python.File\shell\open\command): [HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command] @=”\”C:\\Python25\\python.exe\” \”%1\” %*” This seems to be the controlling setting on my system. The registry setting above adds the “%*” to pass all arguments to python.exe (it was … Read more

OpenSubKey() returns null for a registry key that I can see in regedit.exe

A 32-bit application on a 64-bit OS will be looking at the HKLM\Software\Wow6432Node node by default. To read the 64-bit version of the key, you’ll need to specify the RegistryView: using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) using (var key = hklm.OpenSubKey(@”SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”)) { // key now points to the 64-bit key } The API to do … Read more

Why are other folder paths also added to system PATH with SetX and not only the specified folder path?

Windows creates a copy of the entire environment table of the process starting a new process for the new process. Therefore on start of your C++ application, your application gets the environment table including PATH from parent process, Windows Explorer or in your case Visual Studio. And this PATH is copied for cmd.exe on start … Read more