How to make more than one change in windows registry with this code?
How to add more DWORD keys and values?

#include <Windows.h>
#include <iostream>

using namespace std;

int main()

LONG IReg;
HKEY hKey;
DWORD dwData = 6;
IReg = RegCreateKeyEx
(
    HKEY_LOCAL_MACHINE,
    L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Multimedia\\SystemProfile\\Tasks\\Games",
    0,
    NULL,
    REG_OPTION_NON_VOLATILE,
    KEY_ALL_ACCESS | KEY_WOW64_64KEY,
    NULL,
    &hKey,
    NULL
);
if (IReg != ERROR_SUCCESS)
{
    cout << "Priority add failed & Error No -" << GetLastError() << endl;

}
cout << "Priority add success" << endl;

IReg = RegSetValueEx
(
    hKey,
    L"Priority",
    NULL,
    REG_DWORD,
    (LPBYTE)&dwData,
    sizeof(dwData)
);
if (IReg != ERROR_SUCCESS)
{
    cout << "RegSetValueEx add failed & Error No -" << GetLastError() << endl;
}
cout << "RegSetValueEx add success" << endl;
RegCloseKey(hKey);
return 0;

It looks to me you would duplicate the code starting at about DWORD dwData = 6 to where this code section ends (remember I take it this is your code, not found in the wild and that you write code) and paste that above the return 0; and make changes as you wish.

Next time pay attention to code formatting in your post so there are line numbers and better code formatting.

commented: Thank you sir. I find the solution similar to your answer. Have a good day. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.