|
-
February 27th, 2006, 10:45 AM
#1
DWORD to string
Does anyone know how to convert a DWORD to a string, or char* or char[], or CString etc.
What I am trying to do is read a DWORD value from the registry and put its value in an edit box in a MFC Dialog. And then when the user clicks OK, I'll take that value they typed into the edit box(if they changed it) and put that back into the Registry.
I found out how to go from char* to DWORD but I can't figure out how to go the other way around so when I first read that value from the Registry I can update the edit box with it.
Basically I am trying to display a DWORD value in an edit box.
Thanks
Last edited by JL8843; February 27th, 2006 at 11:08 AM.
-
February 27th, 2006, 11:12 AM
#2
Re: DWORD to string
Have a look at the following link.
Regards
I don't mind that you think slowly but I do mind that you are publishing faster than you think. Wolfgang Pauli, physicist, Nobel laureate (1900-1958)
-
February 27th, 2006, 11:46 AM
#3
Re: DWORD to string
Take a look at these FAQs.
-
February 27th, 2006, 12:07 PM
#4
Re: DWORD to string
Thanks for your responses.
I guess I have to convert the DWORD into an int or decimal representation first for it to display correctly in the edit box.
Right now it is displaying 3i in my edit box.
How would you go about converting the DWORD value into a decimal value?
-
February 27th, 2006, 12:31 PM
#5
Re: DWORD to string
DWORD is nothing by 'typedef' for unsigned long. It hold value within its range.
It is upto programmer how to represent it, how to store value in it - decimal, hexa decimal or octal format; or to use it in calculations or as return value of some expression/function.
Can you be more specific, what you want to achieve?
-
February 27th, 2006, 12:36 PM
#6
Re: DWORD to string
Either with the C runtime function ltoa():
Code:
#include <stdlib.h>
char buffer[32];
ltoa((long)dwValue, buffer, 10);
Or with the WinAPI function wsprinf():
Code:
#include <windows.h>
char buffer[32];
wsprintf(buffer, "%d", dwValue);
Please don't forget to rate users who helped you!
-
February 27th, 2006, 01:03 PM
#7
Re: DWORD to string
 Originally Posted by JL8843
Thanks for your responses.
I guess I have to convert the DWORD into an int or decimal representation first for it to display correctly in the edit box.
Right now it is displaying 3i in my edit box.
How would you go about converting the DWORD value into a decimal value?
Did you read FAQ cilu suggested?
"Programs must be written for people to read, and only incidentally for machines to execute."
-
February 27th, 2006, 02:06 PM
#8
Re: DWORD to string
 Originally Posted by RoboTact
Did you read FAQ cilu suggested?
Yes, I think that I am now able to load the DWORD value into the edit box.
I am still confused however with writing back to the registry.
How do I go about converting an int to a DWORD? Is this just a simple cast?
-
February 27th, 2006, 02:21 PM
#9
Re: DWORD to string
Yes, it's a simple cast between two numeric types. DWORD is actually defined as unsigned int.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|