How to call C APIs like CMC?

  • Thread starter Thread starter Siegfried Heintze
  • Start date Start date
S

Siegfried Heintze

How do I call APIs written in C like CMC? Will PInvoke do the job? I hope I
don't have to write a COM wrapper!
Sieg
 
Platform Invoke ([DllImport]) is used to call *any* function exported from a
DLL. All functions exported from a DLL are C functions (yes, you can put
__declspec(dllexport) on a C++ method, but it will be exported as a C
function hence you have to take into account C++ name mangling and the this
pointer).

If the function is available through a static library then you can only
access the function through managed C++. In this case the managed C++ code
simply calls the function - you don't need any other code.

The COM wrapper objects are only used when you want to call COM code from
..NET code, or if you want to use .NET code from unmanaged code.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top