|
I am in over my head again.
I am getting error C2664 and I did read the Tech note ( something about ANSI improvement) about it and frankly I just do not understand what is the problem and <b>how to fix it in VC6.0.</b>
Do I have to redefine the GUID_DEVCLASS_COMPUTER?
The parameter GUID is defined in both functions as “const GUID*”
The API fails with this error C2664 and C_GetClassImgIndex compiles OK
error C2664: 'SetupDiGetClassImageIndex' : cannot convert parameter 2 from 'const struct _GUID *' to 'struct _GUID *'
Conversion loses qualifiers
Fails
b = SetupDiGetClassImageIndex(&m_imgList, &GUID_DEVCLASS_COMPUTER, &nRootImg);
OK
int n = C_GetClassImgIndex(&GUID_DEVCLASS_COMPUTER);
Any help would be greatly appreciated.
Cheers
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: The API fails with this error C2664 You are not using the API, this is a compiler error.
Vaclav_Sal wrote: cannot convert parameter 2 from 'const struct _GUID *' to 'struct _GUID *' You are passing a const parameter to a function that does not expect one. Use const_cast [^] to remove it. But be sure you understand the potential consequences.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Richard ,
I do not follow your explanation.
In this MSDN doc the second parameter is defined as const GUID*.
Am I using wrong version ot the Setupapi.h?
PS Did you read the title? I did say compiler error.I do appreciate your help, but growing little tired of your sideline remarks,that's all.
http://msdn.microsoft.com/en-us/library/windows/hardware/ff551074(v=vs.85).aspx
BOOL SetupDiGetClassImageIndex(
_In_ PSP_CLASSIMAGELIST_DATA ClassImageListData,
_In_ const GUID *ClassGuid,
_Out_ PINT ImageIndex
);
|
|
|
|
|
Vaclav_Sal wrote: _In_ const GUID *ClassGuid,
The pointer is a constant, not the structure.
|
|
|
|
|
Oh come on man, it is the C language. If the compiler bitches just cast it out. YOU are in control. YO are the master!
|
|
|
|
|
Have you tried something like this:
GUID tmp(GUID_DEVCLASS_COMPUTER);
b = SetupDiGetClassImageIndex(&m_imgList, &tmp, &nRootImg);
|
|
|
|