public eAudioStartup() { eAudioSettingsDelegate eAudioDelegate = new eAudioSettingsDelegate(checkeAudioSettings); IAsyncResult result = eAudioDelegate.BeginInvoke(new AsyncCallback(ResultsReturned), eAudioDelegate); Assembly a = Assembly.GetExecutingAssembly(); System.IO.Stream eAudioIcon = a.GetManifestResourceStream("eAudioStartup.eAudio.ico"); tray = new NotifyIcon(); tray.Icon = new Icon(eAudioIcon); tray.Visible = true; tray.ShowBalloonTip(500, "eAudioStartup Manager", "Waiting for eAudio...", ToolTipIcon.Info); tray.Click += new EventHandler(delegate { tray.ShowBalloonTip(1000, "eAudioStartup Manager", "eAudioManager running...", ToolTipIcon.Info); }); //Thread.Sleep(20000); }
// call back method to capture results private static void ResultsReturned(IAsyncResult iar) { eAudioSettingsDelegate eAudioRunning = (eAudioSettingsDelegate)iar.AsyncState; // get the return value from that method call bool returnValue = eAudioRunning.EndInvoke(iar); if (returnValue) { RegistryKey eAudioKey = Registry.CurrentUser.OpenSubKey(@"Software\acer\eAudio", true); string[] valnames = eAudioKey.GetValueNames(); Int32 val0 = (Int32)eAudioKey.GetValue(valnames[0]); String value0 = System.Convert.ToString(eAudioKey.GetValue(valnames[0])); Int32 val1 = (Int32)eAudioKey.GetValue(valnames[1]); String value1 = System.Convert.ToString(eAudioKey.GetValue(valnames[1])); //Int32 val2 = (Int32)eAudioKey.GetValue(valnames[2]); //String value2 = System.Convert.ToString(eAudioKey.GetValue(valnames[2])); Console.WriteLine(val0); Console.WriteLine(val1); //Set to default rock EQ. eAudioKey.SetValue("EQ", 4); eAudioKey.SetValue("AudioMode", 2); tray.ShowBalloonTip(1000, "eAudioStartup Manager", "eAudio is now running EQ reset to Rock...", ToolTipIcon.Info); Thread.Sleep(2000); } else { tray.ShowBalloonTip(1000, "eAudioStartup Manager", "eAudio has not booted...closing", ToolTipIcon.Info); Thread.Sleep(2000); } tray.Visible = false; Application.Exit(); }