I know hwo to make an API call in VB, but what about in C++?
Thanks ion advance :):)
Printable View
I know hwo to make an API call in VB, but what about in C++?
Thanks ion advance :):)
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);
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.
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.
Most APIs that can be called from a console will accept null for the hWnd parameter..
Not hWnd...I'm talking about the instance handle :D
Well, I'm talking about the Window Handle(like in the MessageBox function). :p
How would you get hold of the hInstance for a console app then?
And what the f*** happened to my avatar? I've got that one with the excitable smileys for some odd reason :confused:
Oh, it's sorted now.
Code:HINSTANCE hInst = GetModuleHandle(NULL);
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.
You have an instance of a module :)