"Converting string retrieved from windows registry to integer"
-
hi, i am using Windows registry to store an integer value on closing of my dialog and running the application again i am retrieving this value.. this retrieved as string and i tried using "atoi()" to convert but iis giving following error. "'atoi' : cannot convert parameter 1 from 'CString' to 'const char *'" and the lines while retrieving the string are.. System::String* valueNames[] = keySoftware->GetValueNames(); for( int i = 0; i < valueNames->Length; i++) { CString strValue = static_cast(keySoftware->GetValue(valueNames[i])); .... .... ....
Harsha
-
hi, i am using Windows registry to store an integer value on closing of my dialog and running the application again i am retrieving this value.. this retrieved as string and i tried using "atoi()" to convert but iis giving following error. "'atoi' : cannot convert parameter 1 from 'CString' to 'const char *'" and the lines while retrieving the string are.. System::String* valueNames[] = keySoftware->GetValueNames(); for( int i = 0; i < valueNames->Length; i++) { CString strValue = static_cast(keySoftware->GetValue(valueNames[i])); .... .... ....
Harsha
-
hi, i am using Windows registry to store an integer value on closing of my dialog and running the application again i am retrieving this value.. this retrieved as string and i tried using "atoi()" to convert but iis giving following error. "'atoi' : cannot convert parameter 1 from 'CString' to 'const char *'" and the lines while retrieving the string are.. System::String* valueNames[] = keySoftware->GetValueNames(); for( int i = 0; i < valueNames->Length; i++) { CString strValue = static_cast(keySoftware->GetValue(valueNames[i])); .... .... ....
Harsha
-
hi, i am using Windows registry to store an integer value on closing of my dialog and running the application again i am retrieving this value.. this retrieved as string and i tried using "atoi()" to convert but iis giving following error. "'atoi' : cannot convert parameter 1 from 'CString' to 'const char *'" and the lines while retrieving the string are.. System::String* valueNames[] = keySoftware->GetValueNames(); for( int i = 0; i < valueNames->Length; i++) { CString strValue = static_cast(keySoftware->GetValue(valueNames[i])); .... .... ....
Harsha
-
hi, i am using Windows registry to store an integer value on closing of my dialog and running the application again i am retrieving this value.. this retrieved as string and i tried using "atoi()" to convert but iis giving following error. "'atoi' : cannot convert parameter 1 from 'CString' to 'const char *'" and the lines while retrieving the string are.. System::String* valueNames[] = keySoftware->GetValueNames(); for( int i = 0; i < valueNames->Length; i++) { CString strValue = static_cast(keySoftware->GetValue(valueNames[i])); .... .... ....
Harsha
-
Do this way, Suppose
strKey
contains the registry value it read and it is a CString object.int nTemp = atoi (strKey.operator LPCSTR ());
This will surely work.
Come online at:- jubinc@skype
Thank you.. i will try this out and let tou know :)
Harsha
-
hi, i am using Windows registry to store an integer value on closing of my dialog and running the application again i am retrieving this value.. this retrieved as string and i tried using "atoi()" to convert but iis giving following error. "'atoi' : cannot convert parameter 1 from 'CString' to 'const char *'" and the lines while retrieving the string are.. System::String* valueNames[] = keySoftware->GetValueNames(); for( int i = 0; i < valueNames->Length; i++) { CString strValue = static_cast(keySoftware->GetValue(valueNames[i])); .... .... ....
Harsha
i wonder why you needed
atol
here. If usingMC++
, then you can useConvert::ToInt32
function for this purpose, instead of mix of all these things.System::String* valueNames[] = keySoftware->GetValueNames();
for( int i = 0; i < valueNames->Length; i++)
{
int nValue = Convert::ToInt32(valueNames[i]);
...
}And use <pre> tags while posting code.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Do this way, Suppose
strKey
contains the registry value it read and it is a CString object.int nTemp = atoi (strKey.operator LPCSTR ());
This will surely work.
Come online at:- jubinc@skype
Never call an operator this way, this is just uggly. You can simply do that:
int nTemp = atoi((LPCSTR)strKey);
But I don't think it will work because if the cast was possible it would have been implicitely done already and you wouldn't have an error.
Cédric Moonen Software developer
Charting control [v1.1]