Results 1 to 10 of 10

Thread: API

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217
    Is there a way to use API calls in normal C++? Would I just declare them normally or...?
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    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)?
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  4. #4
    Guest
    You can use api in any windows program, even the box type.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Wink Thanks

    Thanks, but just to be sure, do I have to include windows.h?
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    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
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    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
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    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);
    }
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width