private void FindAndLoadQuickLinkDLLs()
        {
            RegistryKey reg = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);

            RegistryKey qlRegKeyLoc = null;

            foreach (string s in QuickConstants.QuickLinkRegistryKeyLocations)
            {
                // Try each possible key location.
                qlRegKeyLoc = reg.OpenSubKey(s);
                if (qlRegKeyLoc != null)
                {
                    // Found the key.
                    break;
                }

                if (qlRegKeyLoc == null)
                {
                    // Key not found.
                    continue;
                }
            }

            if (qlRegKeyLoc == null)
            {
                reg = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);

                qlRegKeyLoc = null;
                foreach (string s in QuickConstants.QuickLinkRegistryKeyLocations)
                {
                    // Try each possible key location.
                    qlRegKeyLoc = reg.OpenSubKey(s);
                    if (qlRegKeyLoc != null)
                    {
                        // Found the key.
                        break;
                    }

                    if (qlRegKeyLoc == null)
                    {
                        // Key not found.
                        continue;
                    }
                }
            }

            if (qlRegKeyLoc == null)
            {
                // Key not found!
                throw new Exception("The QuickLinkDLL registry key could not be found.");
            }

            // Path to the QuickLink DLL.
            string qlPath = qlRegKeyLoc.GetValue("Path").ToString();

            if (qlPath == null)
            {
                // Value not found!
                throw new Exception("The QuickLinkDLL path could not be retrieved from the registry.");
            }

            // The path to the Dragonfly capture DLL.
            string dfPath = Path.Combine(Path.GetDirectoryName(qlPath), QuickConstants.PGRFlyCaptureDLLName);

            /* Now we load the DLLs into our address space.  This allows us to
             * use DLLImport without knowing the full path to the DLLs until
             * load time.
             */
            this.dfHandle = Win32LibraryControl.Load(dfPath);
            if ((cpp_long)this.dfHandle == 0)
            {
                // Unable to load the library!
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            this.qlHandle = Win32LibraryControl.Load(qlPath);
            if ((cpp_long)this.qlHandle == 0)
            {
                // Unable to load the library!
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
        }
 private void FreeQuickLinkDLLs()
 {
     Win32LibraryControl.Free(this.qlHandle);
     Win32LibraryControl.Free(this.dfHandle);
 }