示例#1
0
        public static void InitPortTalk()
        {
            PowerSDRconsole = PowerSDR.Console.getConsole();
            if (PowerSDRconsole != null && PowerSDRconsole.neuterPP)
            {
                System.Console.WriteLine("Parallel Port force neutered");
                return;
            }
            else
            {
                System.Console.WriteLine("Parallel Port live!");
            }

            if (Environment.OSVersion.ToString() == "Microsoft Windows NT 5.1.2600.0")
            {
                // check for driver file and copy if needed
                if (!File.Exists(Environment.SystemDirectory + "\\drivers\\porttalk.sys"))
                {
                    File.Copy(Application.StartupPath + "\\porttalk.sys", Environment.SystemDirectory + "\\drivers\\porttalk.sys");
                }

                // check for registry entry
                RegistryKey rk   = null;
                RegistryKey hklm = Registry.LocalMachine.OpenSubKey("SYSTEM", true);
                if (hklm != null)
                {
                    hklm = hklm.OpenSubKey("CurrentControlSet", true);
                }
                if (hklm != null)
                {
                    hklm = hklm.OpenSubKey("Services", true);
                }
                if (hklm != null)
                {
                    rk = hklm.OpenSubKey("PortTalk", true);
                }
                if (rk == null)
                {
                    rk = hklm.CreateSubKey("PortTalk");
                }

                if (rk != null)
                {
                    string[] names = rk.GetValueNames();
                    int      val;
                    foreach (string s in names)
                    {
                        switch (s)
                        {
                        case "ErrorControl":
                            val = (int)rk.GetValue("ErrorControl");
                            if (val != 1)
                            {
                                rk.SetValue("ErrorControl", 1);
                            }
                            break;

                        case "Start":
                            val = (int)rk.GetValue("Start");
                            if (val != 2)
                            {
                                rk.SetValue("Start", 2);
                            }
                            break;

                        case "Type":
                            val = (int)rk.GetValue("Type");
                            if (val != 1)
                            {
                                rk.SetValue("Type", 1);
                            }
                            break;
                        }
                    }
                }
                else                 // key not found, could not create it
                {
                    MessageBox.Show("Error initializing PortTalk");
                }
            }

            InitPortTalkDll();
        }
 public static void setConsole(PowerSDR.Console console)
 {
     m_console = console;
 }