Results 1 to 13 of 13

Thread: API Calls in C++?

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Question

    I know hwo to make an API call in VB, but what about in C++?
    Thanks ion advance
    Amon Ra
    The Power of Learning.

  2. #2
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    Just include the file windows.h and you're set!
    You might want to take a look at www.winprog.org for an easy way to learn the API!

    Ex.

    Code:
    	TCHAR pcBuf[MAX_PATH];
    	GetWindowsDirectory(pcBuf, MAX_PATH);
    	MessageBox(HWND,pcBuf, "Windows folder!", MB_OK);
    	
    	GetSystemDirectory(pcBuf, MAX_PATH);
    	MessageBox(HWND, pcBuf,"System Dir", MB_OK);
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    As CyberCarsten said, just include the windows.h and you are on! Unlike to many that use API in VB, the MSDN can be very very helpful to more advanced (C++) API programming. Be sure to use it.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Also, you can use API calls from a console program, but some of them are made much easier if you use them from a Win32 Application. The main difference being when you open that, you get passed the handle to your program's instance, which is needed for many API calls.
    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

  5. #5
    denniswrenn
    Guest
    Most APIs that can be called from a console will accept null for the hWnd parameter..

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Not hWnd...I'm talking about the instance handle
    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
    denniswrenn
    Guest
    Well, I'm talking about the Window Handle(like in the MessageBox function).

  8. #8
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    How would you get hold of the hInstance for a console app then?
    Harry.

    "From one thing, know ten thousand things."

  9. #9
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    And what the f*** happened to my avatar? I've got that one with the excitable smileys for some odd reason
    Harry.

    "From one thing, know ten thousand things."

  10. #10
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Oh, it's sorted now.
    Harry.

    "From one thing, know ten thousand things."

  11. #11
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    HINSTANCE hInst = GetModuleHandle(NULL);
    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

  12. #12
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Ah right cheers. Odd name for a function that returns a handle to an instance. You'd expect it to be called GetInstanceHandle. Well I would anyway, I suppose there's a good reason for it.
    Harry.

    "From one thing, know ten thousand things."

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You have an instance of a module
    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

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