Compiler error when defining enum for registry
-
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
-
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
Try converting to
ULONG_PTR
or maybeLONG_PTR
instead ofint
, althorough making an enum out of HKEYs seems to be a tiny-bit ugly to me, but this might just be my personal taste. Good luck.> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <
-
Try converting to
ULONG_PTR
or maybeLONG_PTR
instead ofint
, althorough making an enum out of HKEYs seems to be a tiny-bit ugly to me, but this might just be my personal taste. Good luck.> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <