|
Thread: API
-
Nov 2nd, 2000, 11:48 AM
#1
Thread Starter
Addicted Member
Is there a way to use API calls in normal C++? Would I just declare them normally or...?
-
Nov 2nd, 2000, 12:02 PM
#2
Frenzied Member
It depends what compiler you're using, VC++ tends to include them automaticly, otherwise just
Code:
#include <windows.h>
and they'll all be declared for you.
-
Nov 2nd, 2000, 12:05 PM
#3
Thread Starter
Addicted Member
Really?
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, 01:08 PM
#4
You can use api in any windows program, even the box type.
-
Nov 2nd, 2000, 01:24 PM
#5
Thread Starter
Addicted Member
Thanks
Thanks, but just to be sure, do I have to include windows.h?
-
Nov 2nd, 2000, 01:33 PM
#6
Monday Morning Lunatic
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"...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 2nd, 2000, 01:40 PM
#7
Thread Starter
Addicted Member
Could somebody post..?
Could somebody post a full, small example of this? Whenever I try in VC5 it says the functions I use wont work
-
Nov 2nd, 2000, 02:58 PM
#8
Monday Morning Lunatic
Can you post the full errors, please?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2000, 12:58 PM
#9
Thread Starter
Addicted Member
Funny Parksie
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
-
Nov 3rd, 2000, 01:15 PM
#10
Thread Starter
Addicted Member
NM
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);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|