المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Compiler error when defining enum for registry



C++ Programming
08-05-2009, 02:21 PM
Hi,
I am using one of the registy class given in CP.
The keys are defined in .h file like:
enum Keys
{
classesRoot = HKEY_CLASSES_ROOT,
currentUser = HKEY_CURRENT_USER,
localMachine = HKEY_LOCAL_MACHINE,
currentConfig = HKEY_CURRENT_CONFIG,
users = HKEY_USERS,
performanceData = HKEY_PERFORMANCE_DATA,
dynData = HKEY_DYN_DATA
};

When I compile this in VC6.0 it compiles with no errors.
But when I compile the same in visual studio 2003 it gives error like:" Constant expression is not intergral"
If i cast like: "classesRoot=(int)HKEY_CLASSES_ROOT", it throws warning such as "pointer truncation from HEKY to int".
How can I avoid the error.Please suggest.

Regards,
Sunil Kumar