RegSetValueEx() problem

I am trying to add an application to run on startup in Windows. I am using RegSetValueEx() to do this:

1
2
3
4
5
6
7
8
9
10
11
12
int main()

{
	HKEY hkey;
	long regOpenResult;
	const char path[]="C:\\Users\\Gizda\\Documents\\Visual Studio 2010\\Projects\\stuffs\\Debug\\stuffs.exe";
	regOpenResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey);
	LPCSTR stuff = "stuffs";
	RegSetValueEx(hkey,stuff,0,REG_SZ,(BYTE*) path, strlen(path));
	RegCloseKey(hkey);
	return 0;
}


When I compile the code above, it runs fine, does not give any error. When I check for the return value of both ReturnOpenKeyEx and RegSetValueEx, they return ERROR_SUCCESS. But the key is not placed in the registry. Any ideas?

Btw I am running Windows 7 x64.
Do you run this program with administrator privileges? That's my #1 suspect.
I tried it now, but still no change.
Topic archived. No new replies allowed.