Originally Posted by grneyeddvl
in C/C++ there are two basic calling conventions in use:
__stdcall = windows API
__cdecl = standard C/C++
One difference between __stdcall and __cdecl calling conventions has to do with who "pops" the stack at the end of a function, on return.
In windows API functions, the called function restores the stack to it's proper order.
In a "standard C" function, the caller (the program calling the function is responsibe for aligning the stack on return.
Generally, a C programmer doesn't have to mess with aligning the stack, the compiler handles all of that.
Assembly Language programmers always have to do stack maintainance.
There are only rare circumstances where C programmer has to maintain the stack. You would have to be doing something out of the ordinary, (where windows is concerned).
Regarding the question about the code sample you posted above, it looks like that is just an example, (copied from somewhere), that simply illustrates a function prototype.
well, windows doesn't know when to call it , unless you specifically tell windows to call it in your program.
what i'm have problems with how does windows know when to call this function?.
I take it that you are not only new to win-32, but, new to C/C++ programming as well.
In C/C++, each and every function that you (the programmer) writes must be preceded by a "function prototype".
The "prototype" is for the compiler's benefit. It instructs the compiler what that function is supposed to look like, before it encounters it.
Again, simply part of the prototype.
and where does the return value (HRESULT) go when the function returns.
The return value could be any data type: int, double, char, void, ....etc.
Too many to list here.
HRESULT is merely an example.
Notice, I did not have to specify any type of calling convention. The compiler handles all of that for me.
int MyFunction(int p1, p2, p3); // prototype
int hResult, param1, param2, param3; //interger variables
hResult = MyFunction(param1, param2, param3); // call function
... // do something with hResult ..
return 0; // done
IMHO, unless you are doing Assembly Language programming, or some really advanced C programming, you don't need to be overly concerned about the calling conventions used.
Let the compiler handle it.