WINAPI !!!!!!!!!!!

Started by
6 comments, last by Last Attacker 22 years, 9 months ago
Hi! Sorry to bother those who answered my questions for the 3rd time but this is my last one for a while. Ok, you know the function WINAPI? I know that you would use it so: int WINAPI Win_func(VAR_type parrameter) { return 0; }; But I really think that it''s not quite right. Any replies will be welcome! THANKS ONCE MORE! ----------=Last Attacker=---------- ICQ: 120585863 E-mail: laextr@icqmail.com
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
Advertisement
quote:Original post by Last Attacker
Sorry to bother those who answered my questions for the 3rd time but this is my last one for a while. Ok, you know the function WINAPI?

First off, WINAPI is NOT a function! It''s a macro defining the parameters for a windows API function call, usually a FAR PASCAL function call, i.e.

#define WINAPI FAR PASCAL

However this can vary slightly from one version of windows to another (3.x to 2000) and from one type of target file to another (.exe to .dll)

quote:Original post by Last Attacker
I know that you would use it so:
int WINAPI Win_func(VAR_type parrameter)
{
return 0;
};

But I really think that it''s not quite right.



That would be right but you normaly only use it if your defining a windows api function so you probably don''t have to worry about using it in your own programs.
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
WINAPI is a macro that defines the CC - calling convention (ie. _stdcall, _fastcall, _cdecl)

The CC affects the order in which parameters are pushed on the stack and how they are cleaned up.

For the user, you would not need to bother about specifying CC. But if you are writing a static lib or dll, then you need to specify the CC on standalone functions and static class member functions. (Note: Most people, even professional sdks assume _cdecl and don''t specify the CC, which is a troublesome if I want to change the CC in my program)
Do you have any kind of question or do you want to know what that WINAPI thing is used for in the windows procedure?

And simply, do you want to know how to create a window?
:D: What Bill Gates does, is not right!
Do you have any kind of question or do you want to know what that WINAPI thing is used for in the windows procedure?

And simply, do you want to know how to create a window?
:D: What Bill Gates does, is not right!
__stdcall is generally considered a better choice because it is language-independent. You can''t call a COM object or DLL function from VB if it''s __cdecl. However, you can''t use __stdcall for variable numbers of arguments.

Make your judgment about which is better. You can even override thiscall for class functions and use stdcall (com interfaces), which puts the this pointer as the first parameter (so IX::FA() would really be FA(IX*)
VK
What I really wanted to know is, how do you declare a function or procedure like in VB by using the "Declare function" or "Declare sub" stuff.

Thanks again!



----------=Last Attacker=----------

ICQ: 120585863
E-mail: laextr@icqmail.com


Edited by - last attacker on July 3, 2001 4:55:34 PM
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
i''m not sure what you''re trying to do, but my guess is that you''re trying to access windows API functions, there''s no need to declare all these functions in C/C++, just put #include &ltwindows.h> at the top of your source file

for example:

  #include <windows.h>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow){	MessageBox(0, "hello world", "test", 0);	return 0;}  


MessageBox() is an API function, don''t get distracted by the confusing WinMain(), that''s just how the entry point in a windows C/C++ program is defined(cf Sub Main in VB)

you never have to use WINAPI when you want to call windows functions, WINAPI is mostly used for callback functions, you define a function that windows calls for you, like the WinMain() in the example

there are several of these macro''s that all boil down to the same thing: WINAPI, APIENTRY, CALLBACK, PASCAL, ...

This topic is closed to new replies.

Advertisement