Is there a way to use API calls in normal C++? Would I just declare them normally or...?
Printable View
Is there a way to use API calls in normal C++? Would I just declare them normally or...?
It depends what compiler you're using, VC++ tends to include them automaticly, otherwise justand they'll all be declared for you.Code:#include <windows.h>
its really that simple? Can I use an API call in a normal C++ app(not a vc but it is made in VS)?
You can use api in any windows program, even the box type.
Thanks, but just to be sure, do I have to include windows.h?
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"...
Could somebody post a full, small example of this? Whenever I try in VC5 it says the functions I use wont work
Can you post the full errors, please?
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
Nevermind Parksie, I got it working, thanks. Here's the working code for SetCursorPos
Code:#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);
}