473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Removing Certain warning

Jay
Hey There,
I have this line of code:
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey,0,KEY_READ, &OpenKey);

and it produces this warning:
warning C4312: 'type cast' : conversion from 'DWORD' to 'HKEY'
of greater size
What can I do to have this warning be removed?

Thanks!
Jay
(patelj27b at gmail dot com)

Oct 27 '06 #1
7 1606
I have this line of code:
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey,0,KEY_READ, &OpenKey);

and it produces this warning:
warning C4312: 'type cast' : conversion from 'DWORD' to 'HKEY'
of greater size
Hi,
what is the type of RetVal?
RegOpenKeyEx returns a long, not a HKEY. if retVal is a HKEY, that would be
the cause of the problem.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Oct 28 '06 #2
Jay wrote:
Hey There,
I have this line of code:
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey,0,KEY_READ, &OpenKey);

and it produces this warning:
warning C4312: 'type cast' : conversion from 'DWORD' to 'HKEY'
of greater size
What can I do to have this warning be removed?

Thanks!
Jay
(patelj27b at gmail dot com)
Jay:

You need to show us more code. What are the declared types of all the
variables in this line of code?

David Wilkinson

Oct 28 '06 #3
Jay

David Wilkinson wrote:
Jay wrote:
Hey There,
I have this line of code:
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey,0,KEY_READ, &OpenKey);

and it produces this warning:
warning C4312: 'type cast' : conversion from 'DWORD' to 'HKEY'
of greater size
What can I do to have this warning be removed?

Thanks!
Jay
(patelj27b at gmail dot com)

Jay:

You need to show us more code. What are the declared types of all the
variables in this line of code?

David Wilkinson
Hey There,
retVal is declared as a long, subKey is a char [46], and OpenKey is
HKEY. I don't think these have anything to do with it, from what I can
tell it has to do with HKEY_LOCAL_MACHINE being a constant with an int
value, and needing to be of type "HKEY". Any ideas?

Thanks!
Jay
(patelj27b at gmail dot com)

Oct 31 '06 #4
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey,0,KEY_READ, &OpenKey);
retVal is declared as a long, subKey is a char [46], and OpenKey is
HKEY. I don't think these have anything to do with it, from what I can
tell it has to do with HKEY_LOCAL_MACHINE being a constant with an int
value, and needing to be of type "HKEY". Any ideas?
If that is the case, then you can solve the problem with a simple explicit
typecast i think.
(INT_PTR)HKEY_LOCAL_MACHINE

Are you doing this on x64 perhaps?
Because otherwise a handle should be the same size as a DWORD on x386,
unless I am missing something obvious.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Oct 31 '06 #5
Jay

Bruno van Dooren [MVP VC++] wrote:
retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey,0,KEY_READ, &OpenKey);
retVal is declared as a long, subKey is a char [46], and OpenKey is
HKEY. I don't think these have anything to do with it, from what I can
tell it has to do with HKEY_LOCAL_MACHINE being a constant with an int
value, and needing to be of type "HKEY". Any ideas?

If that is the case, then you can solve the problem with a simple explicit
typecast i think.
(INT_PTR)HKEY_LOCAL_MACHINE

Are you doing this on x64 perhaps?
Because otherwise a handle should be the same size as a DWORD on x386,
unless I am missing something obvious.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Thanks for the input, but when I set the line to:
retVal =
RegOpenKeyEx((INT_PTR)HKEY_LOCAL_MACHINE,subKey,0, KEY_READ,&OpenKey);

I just get the error:
error C2664: 'RegOpenKeyExA' : cannot convert parameter 1 from
'INT_PTR' to 'HKEY'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast

Is there something else I should do?

-Jay
(patelj27b at gmail dot com)

Oct 31 '06 #6
Thanks for the input, but when I set the line to:
retVal =
RegOpenKeyEx((INT_PTR)HKEY_LOCAL_MACHINE,subKey,0, KEY_READ,&OpenKey);

I just get the error:
error C2664: 'RegOpenKeyExA' : cannot convert parameter 1 from
'INT_PTR' to 'HKEY'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast

Is there something else I should do?
D'oh.
That what you get when posting with a head full of snot.
Of course I meant
(HKEY)HKEY_LOCAL_MACHINE

But I just checked that constant, and it is defined like this:
(( HKEY ) (ULONG_PTR)((LONG)0x80000002) )
So I don't think the parameter is the problem.

To be sure, I just compiled this with /W4, and got no warnings.
char subKey[] = "test";
HKEY OpenKey;
DWORD retVal =
RegOpenKeyExA(HKEY_LOCAL_MACHINE,subKey,0,KEY_READ ,&OpenKey);

What version of VC++ are you using, and are you really sure that retVal is a
DWORD?

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Nov 1 '06 #7
Jay

Bruno van Dooren [MVP VC++] wrote:
Thanks for the input, but when I set the line to:
retVal =
RegOpenKeyEx((INT_PTR)HKEY_LOCAL_MACHINE,subKey,0, KEY_READ,&OpenKey);

I just get the error:
error C2664: 'RegOpenKeyExA' : cannot convert parameter 1 from
'INT_PTR' to 'HKEY'
Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast

Is there something else I should do?

D'oh.
That what you get when posting with a head full of snot.
Of course I meant
(HKEY)HKEY_LOCAL_MACHINE

But I just checked that constant, and it is defined like this:
(( HKEY ) (ULONG_PTR)((LONG)0x80000002) )
So I don't think the parameter is the problem.

To be sure, I just compiled this with /W4, and got no warnings.
char subKey[] = "test";
HKEY OpenKey;
DWORD retVal =
RegOpenKeyExA(HKEY_LOCAL_MACHINE,subKey,0,KEY_READ ,&OpenKey);

What version of VC++ are you using, and are you really sure that retVal is a
DWORD?

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Mr. Van Dooren,
I am currently using Visual Studio 2003

-Jay
(patelj27b at gmail dot com)

Nov 1 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: D. Alvarado | last post by:
Hello, I have an array that contains numbers. Each element in the array is guaranteed to be unique. Let's say I have another variable which I know for certain is in the array, but I don't know...
2
by: Torsten Bronger | last post by:
Hallöchen! When I add a warning filter with warnings.filterwarnings, how can I get rid of it? I've read about resetwarnings(), but it removes all filters, even those that I didn't install in a...
4
by: sri2097 | last post by:
Hi all, I'm storing number of dictionary values into a file using the 'cPickle' module and then am retrieving it. The following is the code for it - # Code for storing the values in the file...
0
by: Jay | last post by:
Hey There, I have this line of code: retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey,0,KEY_READ,&OpenKey); and it produces this warning: warning C4312: 'type cast' : conversion from 'DWORD' to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.