Click here to Skip to main content
15,905,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Images from an internet explorer images Pin
David Crow1-Nov-05 2:31
David Crow1-Nov-05 2:31 
GeneralRe: Images from an internet explorer images Pin
ThG642-Nov-05 7:58
ThG642-Nov-05 7:58 
Questionhow to get IWebbrowser2 by using HWND? Pin
yj31-Oct-05 22:41
yj31-Oct-05 22:41 
AnswerRe: how to get IWebbrowser2 by using HWND? Pin
yj2-Nov-05 21:38
yj2-Nov-05 21:38 
QuestionBinary files again... Pin
Aqueel31-Oct-05 20:35
Aqueel31-Oct-05 20:35 
AnswerRe: Binary files again... Pin
kakan31-Oct-05 21:22
professionalkakan31-Oct-05 21:22 
AnswerRe: Binary files again... Pin
Aqueel31-Oct-05 23:11
Aqueel31-Oct-05 23:11 
GeneralRe: Binary files again... Pin
kakan1-Nov-05 0:00
professionalkakan1-Nov-05 0:00 
Hi there!
I suspected you wanted an integer, that's why I put an '?' in the text.

You can use either an unsigned int or an unsigned long, they both are 32 bits (== 4 bytes) long (in Win32/VC++).
I suggest You use unsigned int.

But beware! The value can be stored in two different ways, depending on the CPU that wrote the file (or the specs of the file). Little endian and Big endian. Intel CPU's use little endian, Motorola CPU's (Macintosh) use big endian.
If you want to know more about endianness, Google for "endian intel motorola"

So if the value you get is incorrect, the file is written using big endian. Then you will need to convert the value you read to little endian.
Here is a function that will do that for you. Call it only if you need it:

<code>
void SwapInt(void* ap)
{
unsigned char* p;
unsigned int a;

p = (unsigned char*) ap;
a = (unsigned int) p[0];
p[0] = p[3];
p[3] = (unsigned char) a;
a = (unsigned int) p[2];
p[2] = p[1];
p[1] = (unsigned char) a;
}

Usage:
unsigned int ui;
ui = <something>;

// Now convert ui from big endian to little endian
SwapInt(&ui);
// Now ui is in little endian
</code>




-- modified at 7:14 Tuesday 1st November, 2005
AnswerRe: Binary files again... Pin
kakan1-Nov-05 0:23
professionalkakan1-Nov-05 0:23 
QuestionHow to join a computer to the domain?? Pin
Rick Pan31-Oct-05 19:46
Rick Pan31-Oct-05 19:46 
QuestionTransparent image Pin
samira forooghi31-Oct-05 19:15
samira forooghi31-Oct-05 19:15 
AnswerRe: Transparent image Pin
Mircea Puiu31-Oct-05 20:34
Mircea Puiu31-Oct-05 20:34 
QuestionBinary files Pin
Aqueel31-Oct-05 18:22
Aqueel31-Oct-05 18:22 
AnswerRe: Binary files Pin
kakan31-Oct-05 19:47
professionalkakan31-Oct-05 19:47 
QuestionProgram Files special folder location. Pin
Martin Marvinski31-Oct-05 16:37
Martin Marvinski31-Oct-05 16:37 
AnswerRe: Program Files special folder location. Pin
khan++31-Oct-05 17:53
khan++31-Oct-05 17:53 
QuestionMFC FormView Pin
ltallman31-Oct-05 16:33
ltallman31-Oct-05 16:33 
AnswerRe: MFC FormView Pin
Christian Graus31-Oct-05 16:35
protectorChristian Graus31-Oct-05 16:35 
AnswerRe: MFC FormView Pin
Arman S.31-Oct-05 21:07
Arman S.31-Oct-05 21:07 
QuestionUnicode, hexadecimal and japanese. Pin
samkook31-Oct-05 14:33
samkook31-Oct-05 14:33 
AnswerRe: Unicode, hexadecimal and japanese. Pin
__yb31-Oct-05 21:20
__yb31-Oct-05 21:20 
GeneralRe: Unicode, hexadecimal and japanese. Pin
samkook1-Nov-05 7:31
samkook1-Nov-05 7:31 
GeneralRe: Unicode, hexadecimal and japanese. Pin
__yb1-Nov-05 11:51
__yb1-Nov-05 11:51 
GeneralRe: Unicode, hexadecimal and japanese. Pin
samkook1-Nov-05 15:40
samkook1-Nov-05 15:40 
QuestionDebugged some strange Error and Now ??? Pin
tbrake31-Oct-05 10:04
tbrake31-Oct-05 10:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.