473,404 Members | 2,187 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,404 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 1607
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.