L
learning
I'm trying to make a map to store the static information of pairs of
string and hkey. So here is the code I ahve so far which DOES NOT
compile. Since I am very new to STL, I do not know how to fix it.
typedef std::map<LPCWSTR,HKEY> MapType;
typedef MapType::value_type ValuePair;
MapType keyMap
keyMap.insert(ValuePair("HKCR",HKEY_CLASSES_ROOT));
keyMap.insert(ValuePair("HKLM",HKEY_LOCAL_MACHINE));
keyMap.insert(ValuePair("HKCR",HKEY_CURRENT_USER));
keyMap.insert(ValuePair("HKU",HKEY_USERS));
keyMap.insert(ValuePair("HKDD",HKEY_DYN_DATA));
so that later on I can use it as this:
WalkRegistry("HKLM","Software\\ActiveState");
The WalkRegistry has body of follows:
HRESULT WalkRegistry(LPCWSTR rootKey,LPCWSTR subKey){
HRESULT ret=S_FAIL;
HKEY hSubkey=NULL;
if(ERROR_SUCCESS==::RegOpenKeyEx(rootKey,subKeyNULL,KEY_READ,&hSubkey))
{
::RegCloseKey(hSubkey);
} else {
std::cout<<"error"<<std::endl;
};
return ret;
}
Can I use STL this way?
Thanks
string and hkey. So here is the code I ahve so far which DOES NOT
compile. Since I am very new to STL, I do not know how to fix it.
typedef std::map<LPCWSTR,HKEY> MapType;
typedef MapType::value_type ValuePair;
MapType keyMap
keyMap.insert(ValuePair("HKCR",HKEY_CLASSES_ROOT));
keyMap.insert(ValuePair("HKLM",HKEY_LOCAL_MACHINE));
keyMap.insert(ValuePair("HKCR",HKEY_CURRENT_USER));
keyMap.insert(ValuePair("HKU",HKEY_USERS));
keyMap.insert(ValuePair("HKDD",HKEY_DYN_DATA));
so that later on I can use it as this:
WalkRegistry("HKLM","Software\\ActiveState");
The WalkRegistry has body of follows:
HRESULT WalkRegistry(LPCWSTR rootKey,LPCWSTR subKey){
HRESULT ret=S_FAIL;
HKEY hSubkey=NULL;
if(ERROR_SUCCESS==::RegOpenKeyEx(rootKey,subKeyNULL,KEY_READ,&hSubkey))
{
::RegCloseKey(hSubkey);
} else {
std::cout<<"error"<<std::endl;
};
return ret;
}
Can I use STL this way?
Thanks