views:

375

answers:

3

Hi There, If get a gring from the registry and it correctly displays when I place it in a message box. ::MessageBoxW(0, (LPCWSTR)achValue, _T("Found"), MB_YESNO);

The value is stored in archValue which is a DWORD. What I want to do is compare it to the following string "2.0.7045.0" but strcmp fails to work for me.

Any ideas on how to do this wiould be greatly appreciated. Pretty rubbish at c++ and I cant debug easily as its in a dll.

Much appreciated

Tony

+2  A: 

You need to use the wide char version of strcmp: wcscmp.

chris
thanks man,Feel like a real dummy. But im learning :)
TonyNeallon
A: 

The question is confusing; you have problem getting the data from the registry or doing a strcmp ?

You get a DWORD (???) out of the registry that should be something like "2.0.7045.0" ? aren't you certain it's not a string (REG_SZ) ?

If you can get the string out of the registry, you should be able to do a string compare; remember that strcmp (or other similar functions/methods) return 0 (zero) if the strings are equals.

Max
A: 

You have hells blend of strings.

MessageBoxW - works with unicode strings.
_T("Found") - macro which add unicode specifier if needed (dpeneded from define in prject settings).
LPCWSTR - unicode string (const wchar_t*).
strcmp - compare for non unicode strings.

you should use one type of all function. w or t or non-unicode strings.

bb