Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a registry key the path is HKEY_CURRENT_USER\\SOFTWARE\\MyRegDemo

in that I have 6 DWORD Values

I want to open the key and loop through the values and get and set values from integer array.

What I have tried:

void CRegistryDemoDlg::OnBnClickedSet()
{
	// TODO: Add your control notification handler code here
int values[6]={0,0,0,0,0,0};
	CRegKey reg;

	HKEY m_hKeyParent=HKEY_CURRENT_USER;

	LPCTSTR m_myKey=L"\\Software\\MyRegDemo";

	reg.Create(m_hKeyParent,m_myKey);

	if(reg.Open(m_hKeyParent,m_myKey)==ERROR_SUCCESS)
	{
		//Here I want to set the values for each entry from array values..
                //using for loop
		reg.Close();
	}
}

void CRegistryDemoDlg::OnBnClickedGet()
{
	// TODO: Add your control notification handler code here
	CRegKey reg;
int values[6];
	HKEY m_hkeyParent=HKEY_CURRENT_USER;
	LPCTSTR m_myKey=L"\\Software\\MyRegDemo";
	DWORD dvalue;
	if(reg.Open(m_hkeyParent,m_myKey)==ERROR_SUCCESS)
	{
		//Here I want to get the values from registry through loop in values
		reg.Close();
	}
}
Posted
Updated 28-Feb-17 21:17pm

1 solution

In order to write, you may either use a loop, calling at each iteration SetWORDValue or SetQWORDValue (as appropriate) or, without the loop, calling just one time SetBinaryValue (see CRegKey Class[^]).
You may read back the data in a similar way.
You might also have a look at one (or more) CodeProject article(s) on the Registry topic[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900