PDA

Click to See Complete Forum and Search --> : API


Chris_SE
Nov 2nd, 2000, 10:48 AM
Is there a way to use API calls in normal C++? Would I just declare them normally or...?

Sam Finch
Nov 2nd, 2000, 11:02 AM
It depends what compiler you're using, VC++ tends to include them automaticly, otherwise just #include <windows.h> and they'll all be declared for you.

Chris_SE
Nov 2nd, 2000, 11:05 AM
its really that simple? Can I use an API call in a normal C++ app(not a vc but it is made in VS)?

Nov 2nd, 2000, 12:08 PM
You can use api in any windows program, even the box type.

Chris_SE
Nov 2nd, 2000, 12:24 PM
Thanks, but just to be sure, do I have to include windows.h?

parksie
Nov 2nd, 2000, 12:33 PM
Any program that runs under windows (console or windowed) automatically has access to Win32 services, like dynamic linking. Therefore, any compiler/linker can produce them. In c++, the definitions are all in the headers, so for the Win32 API, include windows.h.

PS: And please...you can't get a "VC++ application"...

Chris_SE
Nov 2nd, 2000, 12:40 PM
Could somebody post a full, small example of this? Whenever I try in VC5 it says the functions I use wont work

parksie
Nov 2nd, 2000, 01:58 PM
Can you post the full errors, please?

Chris_SE
Nov 3rd, 2000, 11:58 AM
I actually meant just a working example. When I use an API(in this case Beep) as a test, it says the function isnt defined. I have included the windows.h also

Chris_SE
Nov 3rd, 2000, 12:15 PM
Nevermind Parksie, I got it working, thanks. Here's the working code for SetCursorPos

#include <iostream.h>
#include <windows.h>

//Declare Function SetCursorPos Lib "user32" Alias //"SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long

void main()
{
int x=100, y=100;
SetCursorPos(x,y);
}