I'm in C++,
can anyone tell me how to declare external API function ?

some short sample code will be very helpful.


Thanks in advance.

Re: External API Function by Lord2702

Lord2702
Sat Oct 02 17:13:55 CDT 2004

I preassume you are using Managed Extension of C++, check the MSDN
documentation, for P-Invoke.

"Alfred" <anonymous@discussions.microsoft.com> wrote in message
news:u1ICQO5pEHA.2032@TK2MSFTNGP10.phx.gbl...
>
> I'm in C++,
> can anyone tell me how to declare external API function ?
>
> some short sample code will be very helpful.
>
>
> Thanks in advance.
>
>



Re: External API Function by Tim

Tim
Sat Oct 02 17:21:24 CDT 2004

"Alfred" <anonymous@discussions.microsoft.com> wrote:
>
>I'm in C++,
>can anyone tell me how to declare external API function ?
>
>some short sample code will be very helpful.

Do you mean a Windows API function? All of the Windows API functions are
already declared in platform SDK header files. You shouldn't need to do
them yourself.

If not, perhaps you could elaborate on what you want.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc

Re: External API Function by Alfred

Alfred
Sun Oct 03 20:47:05 CDT 2004

Sorry, I'm new in C++.
in VB, i need to declare a Windows API that i need to use as follow;

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String,
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long

and call it as ;
ShellExecute(,,,,)

so in this example, how can i do it in C++ ??

Thanks!!





"Tim Roberts" <timr@probo.com> wrote in message
news:pdaul01b5rl6rqmufgqkr3cenqpefkvp3e@4ax.com...
> "Alfred" <anonymous@discussions.microsoft.com> wrote:
>>
>>I'm in C++,
>>can anyone tell me how to declare external API function ?
>>
>>some short sample code will be very helpful.
>
> Do you mean a Windows API function? All of the Windows API functions are
> already declared in platform SDK header files. You shouldn't need to do
> them yourself.
>
> If not, perhaps you could elaborate on what you want.
> --
> - Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc



Re: External API Function by Scott

Scott
Sun Oct 03 22:19:36 CDT 2004

Alfred wrote:
> Sorry, I'm new in C++.
> in VB, i need to declare a Windows API that i need to use as follow;
>
> Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
> (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String,
> ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
> Long) As Long
>
> and call it as ;
> ShellExecute(,,,,)
>
> so in this example, how can i do it in C++ ??
>
> Thanks!!

C++ is very different from VB. In C++ you should never, ever type in
the Windows API declarations.

The API declarations are in *.h files provided by Microsoft. Look up
the API you want to use in MSDN. The description will tell you which h
file to #include.

#include "Shellapi.h"

int main(int argc, char* argv[])
{
ShellExecute(...);
return 0;
}

In practice, the API .h file includes are actually placed in the
stdafx.h project file, and then stdafx.h is included in each cpp file.
This technique speeds up compilations.

--
Scott McPhillips [VC++ MVP]