Post
Topic
Board Mining (Altcoins)
Merits 2 from 1 user
Re: [Tool] AMD-Compute-Switcher for switch automatically to compute mode
by
Paedy
on 25/01/2018, 16:15:53 UTC
⭐ Merited by xandry (2)
executables with no source.

Yea you are right. But when I started I wanted to create a much bigger software as it is now.
I planned some features for the future so this is not the final version  Cool

Source code from 1.0.0:
Code:
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace AMD_Compute_Switcher
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            RegistryKey localMachineKey = Registry.LocalMachine;
            RegistryKey softwareKey = localMachineKey.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}");
            var cardFolders = softwareKey.GetSubKeyNames();
            Dictionary results = new Dictionary();
            int notComputeMode = 0;
            int tmp;

            foreach (var cardFolder in cardFolders)
                if (int.TryParse(cardFolder, out tmp))
                {
                    RegistryKey cardRegistry = null;
                    try
                    {
                        cardRegistry = softwareKey.OpenSubKey(cardFolder);
                    }
                    catch (Exception) { }
                    if (cardRegistry != null)
                    {
                        var KMD_EnableInternalLargePage = cardRegistry.GetValue("KMD_EnableInternalLargePage");
                        if (KMD_EnableInternalLargePage == null || KMD_EnableInternalLargePage.ToString() != "2")
                        {
                            notComputeMode++;
                            results.Add(cardFolder, "Not in compute mode");
                        }
                        else
                        {
                            results.Add(cardFolder, "Compute mode");
                        }
                    }
                }

            var cardString = "All cards will be switched to " + (notComputeMode > 0 ? "compute" : "graphics") + " mode!\n";
            foreach (var result in results)
            {
                cardString += "\n" + result.Key + ": " + result.Value;
            }

            if (MessageBox.Show(cardString, "Do you want to switch?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
            {
                results = new Dictionary();

                foreach (var cardFolder in cardFolders)
                    if (int.TryParse(cardFolder, out tmp))
                    {
                        RegistryKey cardRegistry = null;
                        try
                        {
                            cardRegistry = softwareKey.OpenSubKey(cardFolder, true);
                        }
                        catch (Exception) { }
                        if (cardRegistry != null)
                        {
                            if (notComputeMode > 0)
                            {
                                /** Switch all to compute mode */
                                try { cardRegistry.SetValue("KMD_EnableInternalLargePage", "2", RegistryValueKind.DWord); results.Add(cardFolder, "Success"); }
                                catch(Exception ex) { results.Add(cardFolder, "Error: " + ex.Message); }
                            }
                            else
                            {
                                /** Switch all to graphics mode */
                                try { cardRegistry.DeleteValue("KMD_EnableInternalLargePage"); results.Add(cardFolder, "Success"); }
                                catch (Exception ex) { results.Add(cardFolder, "Error: " + ex.Message); }
                            }
                        }
                    }
               
                cardString = "Switched successfully to " + (notComputeMode > 0 ? "compute" : "graphics") + " mode!\n";
                foreach (var result in results)
                {
                    cardString += "\n" + result.Key + ": " + result.Value;
                }

                MessageBox.Show(cardString, "Switched successfully!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}