Hi, I'm creating a rule in the registry using c ++ with QT and the windows function for it incorporates the following libraries:
#include <iostream>
#include <windows.h>
#include <conio.h>
Then I create the rule using the following example:
//asignamos key el valor nulo
HKEY key = 0;
//elegimos la ruta donde se creara
LPCTSTR ruta = TEXT("SOFTWARE\Microsoft\Windows\CurrentVersion\Run\");
//con status podemos saber si se creo correctamente
long status = RegOpenKey(HKEY_CURRENT_USER, ruta, &key);
if (status != 0)
{
cout << "Win error: " << GetLastError() << endl;
}
else
{
//cout << "Nombre de la subclave: ";
string subclave="System";
//getline(cin, subclave);
cout << "Valor de la subclave: ";
string valor="C:\miprograma.exe";
//getline(cin, valor);
LPCTSTR _subclave = TEXT(subclave.c_str());
LPCTSTR _valor = TEXT(valor.c_str());
long crear = RegSetValueEx(key, _subclave, 0, REG_SZ, (LPBYTE) _valor, strlen(_valor) * sizeof(char));
if (crear != 0)
{
cout << "Win error: " << GetLastError() << endl;
}
else
{
cout << "Subclave creada correctamente" << endl;
}
}
RegCloseKey(key);
But that gives me the following errors:
My question is in which you can not use iostream or use the following code? It should work, I do not know why I get these errors since I included the libraries. Finally, I need another way to create qsettings for the application I'm creating that will come with this option in my desktop application.