for (int i = 0; i < (int)dwSize; i++)
printf("%02X%c", buffer[i], (i%16==15)?'\n':' ');
printf("\n");
}
srelu
January 23rd, 2008, 11:45 PM
I don't know how you check what you have in the registry.
If you copied the content of the registry key somewhere and compare it against the results you get with your software, the data will not be the same if you moved to work at another computer or if you started another operating system on a multiboot computer.
If you just copied the data, open the registry editor again to check if your copy is still valid.
If you have the registry editor already opened, press F5 to refresh the displayed data (you never know, it may be something, even your app, that modifies it.)
Check the return value of RegQueryValueEx.
Do you have full rights to access the registry ?
XTJoeyTX
January 24th, 2008, 12:55 AM
Actually it seems i'm totally stupid :(.
I used a program earlier to alter my DigitalProductId. The Reg-Edit seems to not reflect it (and it does restore to the correct value on restart of computer).
Anyway, I used the program again to change it and I seen it changed to the correct value that the program changed it to as well as what my program says.
Thanks for the help guys, i feel embarrassed :(.
kirants
January 24th, 2008, 01:00 AM
Thanks for the help guys, i feel embarrassed :(.
Mistakes do happen, so take it easy :wave: After all, all's well that ends well ;)
XTJoeyTX
January 26th, 2008, 05:49 AM
Sorry to 'bump' the topic, but does anyone know a way to combine two characters into a hex-integer.
I've been trying by messing with sprintf, but with no luck :(
And thanks so far for everybody who helped me :)
kirants
January 26th, 2008, 10:45 AM
example please. Data sample and what your expected result is.
XTJoeyTX
January 26th, 2008, 02:13 PM
data would be every two-characters -> 1 character.
68656c6c6f -> "hello"
0xC0000005
January 26th, 2008, 02:44 PM
Your requirements are still not clear. "hello" already is a an array of hex values. It's just a matter of how you work with the data.
If you print each element of either array formatted as a char (%c) you will see "hello." If you print each element of either array formatted as hex (%02x) you will see 68, 65, 6c...
XTJoeyTX
January 27th, 2008, 12:28 AM
Your requirements are still not clear. "hello" already is a an array of hex values. It's just a matter of how you work with the data.
If you print each element of either array formatted as a char (%c) you will see "hello." If you print each element of either array formatted as hex (%02x) you will see 68, 65, 6c...
yes but the string is already in hex-form -- i'd need to get that back into text.
0xC0000005
January 28th, 2008, 01:13 PM
Is this what you are trying to do?
std::string HexStringToText(const char *pHex)
{
// Number of hex character pairs in pHex
const int length = strlen(pHex) / 2;
// Declare string and set number of characters - including one extra for '\0'
std::string text;
text.resize(length+1);
// Copy each hex pair to the text string...
for( int i=0; i<length; ++i ){
// Scan hex pair into integer
int c;
sscanf(pHex+2*i,"%02x",&c);
// Copy to string
text[i] = c;
}
// Add final '\0'
text[length] = '\0';
// Return text string to caller
return text;
}
const std::string text = HexStringToText("68656c6c6f"); // text = "hello"
If not, then you still need to clarify. There are many ways of accomplishing a task like this so my solution is not the only one - and maybe not even the simplest one.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.