|
-
Apr 11th, 2001, 07:05 PM
#1
Thread Starter
Hyperactive Member
I know hwo to make an API call in VB, but what about in C++?
Thanks ion advance 
Amon Ra
The Power of Learning.
-
Apr 12th, 2001, 04:33 AM
#2
Frenzied Member
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);
-
Apr 12th, 2001, 05:01 AM
#3
Frenzied Member
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.
-
Apr 12th, 2001, 07:56 AM
#4
Monday Morning Lunatic
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
-
Apr 12th, 2001, 05:38 PM
#5
Most APIs that can be called from a console will accept null for the hWnd parameter..
-
Apr 12th, 2001, 05:51 PM
#6
Monday Morning Lunatic
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
-
Apr 12th, 2001, 05:56 PM
#7
Well, I'm talking about the Window Handle(like in the MessageBox function).
-
Apr 14th, 2001, 02:12 PM
#8
Frenzied Member
How would you get hold of the hInstance for a console app then?
Harry.
"From one thing, know ten thousand things."
-
Apr 14th, 2001, 02:14 PM
#9
Frenzied Member
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."
-
Apr 14th, 2001, 02:15 PM
#10
Frenzied Member
Harry.
"From one thing, know ten thousand things."
-
Apr 14th, 2001, 02:16 PM
#11
Monday Morning Lunatic
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
-
Apr 15th, 2001, 07:29 PM
#12
Frenzied Member
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."
-
Apr 16th, 2001, 08:17 AM
#13
Monday Morning Lunatic
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|