Hi everyone.I have a strange problem.I've written a class which handles registry keys and values of which there are two functions
template<> unsigned long RegistryEntry::GetValue <unsigned long> (std::string Name) {
unsigned long Value;
unsigned long DataSize;
assert (RegQueryValueEx (Key,Name.c_str(),0,NULL,(unsigned char*)&Value,
&DataSize)==ERROR_SUCCESS);
return Value;
}
template <> char* RegistryEntry::GetValue <char*> (std::string Name) {
char Value[1024];
memset (Value,0,sizeof(Value)/sizeof(char));
unsigned long DataSize;
assert (RegQueryValueEx (Key,Name.c_str(),0,NULL,(unsigned char*)Value,
&DataSize)==ERROR_SUCCESS);
return Value;
}
When called subsequently the second one always crashes unless 'i give it a break'
RegistryEntry Reg(HKEY_CURRENT_USER,"Booth");
std::cout << Reg.GetValue <unsiged long> ("one");
Sleep(1); //without this the following function fails
std::cout << Reg.GetValue <char*> ("two");
I don't know much about pipeline stalls or whatever but i think there shouldn't be a problem with WinApi functions which are written by professionals.What could be the problem ?