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

How to read value of a registry key c#

You need to first add using Microsoft.Win32; to your code page. Then you can begin to use the Registry classes: try { using (RegistryKey key = Registry.LocalMachine.OpenSubKey(“Software\\Wow6432Node\\MySQL AB\\MySQL Connector\\Net”)) { if (key != null) { Object o = key.GetValue(“Version”); if (o != null) { Version version = new Version(o as String); //”as” because it’s REG_SZ…otherwise … 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

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

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

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.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)