Esempio n. 1
0
 /// <summary>
 /// Gets local IQFeed socket ports from the registry
 /// </summary>
 /// <param name="sPort"></param>
 /// <returns></returns>
 private int GetIQFeedPort(string sPort)
 {
     int iReturn = 0;
     MyRegistryKey key = MyRegistry.CurrentUser.OpenSubKey("Software\\DTN\\IQFeed\\Startup");
     //RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\DTN\\IQFeed\\Startup");
     if (key != null)
     {
         string sData = "";
         switch (sPort)
         {
             case "Level1":
                 // the default port for Level 1 data is 5009.
                 sData = key.GetValue("Level1Port", "5009").ToString();
                 break;
             case "Lookup":
                 // the default port for Lookup data is 9100.
                 sData = key.GetValue("LookupPort", "9100").ToString();
                 break;
             case "Level2":
                 // the default port for Level 2 data is 9200.
                 sData = key.GetValue("Level2Port", "9200").ToString();
                 break;
             case "Admin":
                 // the default port for Admin data is 9300.
                 sData = key.GetValue("AdminPort", "9300").ToString();
                 break;
             case "Derivative":
                 // the default port for derivative data is 9400
                 sData = key.GetValue("DerivativePort", "9400").ToString();
                 break;
         }
         iReturn = Convert.ToInt32(sData);
     }
     return iReturn;
 }
Esempio n. 2
0
        /// <summary>
        /// Event handler for the form load event.  
        ///     It controls updating the form controls
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LaunchingTheFeedForm_Load(object sender, EventArgs e)
        {
            IQ_Config config = new IQ_Config();
            txtProductID.Text = config.getProductID();
            /*
             * Start code to check if IQFeed is installed
             */

            // IQFeed Installation directory is stored in the registry key:
            // HKLM\Software\DTN\IQFeed\EXEDIR
            MyRegistryKey key = MyRegistry.LocalMachine.OpenSubKey("SOFTWARE\\DTN\\IQFeed", true);
            if (key == null)
            {
                // if it isn't in that location, it is possible the user is running and x64 OS.  Check the windows virtualized registry location
                key = MyRegistry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\DTN\\IQFeed", true);
            }
            if (key != null)
            {
                string sLocation = key.GetValue("EXEDIR", "").ToString();
                // close the key since we don't need it anymore
                key.Close();
                // verify there is a \ on the end before we append the exe name
                if (!(sLocation.EndsWith("\\") || sLocation.EndsWith("/")))
                {
                    sLocation += "\\";
                }
                sLocation += "IQConnect.exe";
                // update the location in the text box
                txtIQConnectLocation.Text = sLocation;
            }
            else
            {
                MessageBox.Show(String.Format("Unable to find IQFeed Installation.\nDid you forget Install IQFeed?\nMake sure you installed more than just the developer package."), "Could not find IQFeed");
                txtIQConnectLocation.Text = "IQFeed Not Installed";
            }
            /*
             * end code to check if IQFeed is installed
             */

            /*
             * Start code to grab IQFeed settings from the registry
             */

            // pull the login and password, save login info, and autoconnect settings out of the 
            // registry (if they are already stored)
            key = null;
            key = MyRegistry.CurrentUser.OpenSubKey("Software\\DTN\\IQFeed\\Startup", true);

            // NOTE: we don't need to check for the virtualized registry key on x64 here since these values are in the HKEY_CURRENT_USER hive.

            if (key != null)
            {
                string sData = key.GetValue("Login", "").ToString();
                txtLoginID.Text = sData;
                sData = key.GetValue("Password", "").ToString();
                txtPassword.Text = sData;
                sData = key.GetValue("AutoConnect", "0").ToString();
                if (sData.Equals("1"))
                {
                    ckbxAutoconnect.Checked = true;
                }
                sData = key.GetValue("SaveLoginPassword", "0").ToString();
                if (sData.Equals("1"))
                {
                    ckbxSaveLoginInfo.Checked = true;
                }
            }

            /*
             * End code to check if IQFeed is installed
             */

            // populate the productversion from the assembly from this app
            txtProductVersion.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }