I have a development in C# and Winform for Windows which has an installer.msi
This development includes a web container that implements the library CefSharp
; which I like for its low ram memory consumption.
The problem is that by default all the pages that I open are executed implementing the dedicated graphic; and I want that by default if there is a dedicated graphics card it will be pulled for hardware acceleration.
- In between investigating a solution is for the user to go and touch the GPU usage log in System and change the option to high performance:
So this doesn't really help me since I depend on the user having to make configurations or change on their device, so I have the following doubts:
Is there a way in C# to force the program to pull the dedicated graph if it exists for the execution of all processes and threads?
my program starts here:
using System;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
namespace Web_Desktop
{
public partial class Loader : Form
{
public VarManager varManager = new VarManager();
public Common commonClass = new Common();
public XmlManager xmlManager = new XmlManager();
public WebSelector webSelector;
public Loader()
{
InitializeComponent();
}
public void StartUp()
{
bool filecheck = File.Exists(varManager.configfile);
if (!filecheck)
{
if (varManager.isAdministrator)
{
xmlManager.CreateConfXML();
}
else
{
commonClass.RestartApp(true);
}
}
else
{
bool checkRunAs = false;
XmlNodeList admSetting = xmlManager.ReadRunAS();
XmlNode nodoAdm = admSetting.Item(0);
if (nodoAdm.InnerText == "true")
{
checkRunAs = true;
}
if (checkRunAs && !varManager.isAdministrator)
{
commonClass.RestartApp(true);
}
else
{
webSelector = new WebSelector(this);
Thread.Sleep(1500);
webSelector.ShowDialog();
}
}
}
private void Loader_Load(object sender, EventArgs e)
{
Thread thread = new Thread(StartUp);
thread.Start();
}
private void Loader_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
}
}
Currently it is possible to speed up an application using native C# code but this requires a lot of code and extensive knowledge about the API from Intel, AMD and nvidia.
For this project I chose to use another method; in which Windows configuration profiles are used.
When starting the Application we can execute this code:
which will add the application we want to speed up to the registry.
As an addition to this I am also using
CefSharp
, I have had to add it to the Registry as well.