1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
void SettingsDialog::on_buttonSet_clicked(){
const char *regPath ="Software\\Microsoft\\Windows\\Currentversion\\Run";
const char *text="C:\\Program Files\\Aspect\\NoteBlock\\NoteBlock.exe /minimized";
const char *minimizedtext="C:\\Program Files\\Aspect\\NoteBlock\\NoteBlock.exe";
LPCSTR subkey = "NoteBlock";
if(ui->startUp->isChecked()){
HKEY hkey;
if(RegOpenKeyExA(HKEY_CURRENT_USER, regPath,0,KEY_ALL_ACCESS,&hkey)!=ERROR_SUCCESS){
QMessageBox::critical(parent, "Error", "Error opening registry files.");
return;
}
if(ui->minimized->isChecked()){
if(RegSetValueExA(hkey, subkey,0,REG_SZ,(BYTE*)text,strlen(text))!=ERROR_SUCCESS){
QMessageBox::critical(parent, "Error", "Error creating registry file.");
return;
}
}
else{
if(RegSetValueExA(hkey, subkey,0,REG_SZ,(BYTE*)minimizedtext,strlen(minimizedtext))!=ERROR_SUCCESS){
QMessageBox::critical(parent, "Error", "Error creating registry file.");
return;
}
}
if(RegCloseKey(hkey)!=ERROR_SUCCESS){
QMessageBox::critical(parent, "Error", "Error closing registry files.");
return;
}
s->setStartUp(true);
}
else{
HKEY hkey;
if(RegOpenKeyExA(HKEY_CURRENT_USER, regPath,0,KEY_ALL_ACCESS,&hkey)!=ERROR_SUCCESS){
QMessageBox::critical(parent, "Error", "Error opening registry files.");
return;
}
long res = RegDeleteKeyA(hkey, subkey);
if(res!=ERROR_SUCCESS){
QMessageBox::critical(parent, "Error", "Error removing registry file.");
QMessageBox::critical(parent, "Error", QString::number(res));
return;
}
if(RegCloseKey(hkey)!=ERROR_SUCCESS){
QMessageBox::critical(parent, "Error", "Error closing registry files.");
return;
}
s->setStartUp(false);
}
s->setMinimized(ui->minimized->isChecked());
s->save();
QMessageBox::information(parent, "Success", "Settings were sucessfuly set.");
this->hide();
}
the error code is ERROR_FILE_NOT_FOUND
| |