Hi Ozzie,
There are different ways to go about this, depending on how you want
the C++ libraries to look.
- One way is to make an interface in C# that implements the Excel
integration, and keeping .Net out of the the C++ library. In this case
you'd make a C# class (either in a .dll or just as text in a .dna
file) that using P/Invoke with the [DllImport] attribute to talk to
your native C/C++ functions. The C# class can then contain any
parameter handling you need, as well as the function and argument help
strings and the like. So your C/C++ library stays as a native
calculation library.
- Another approach is to make a .Net .dll using the C++/CLR support in
Visual Studio. You can make .Net libraries in C++, and seamlessly
combine native code and libraries - selecting Visual C++ -> CLR ->
Class Library from the New Project wizard gets you started. The
function would look something like this:
#pragma once
using namespace System;
namespace CPPTest {
public ref class Class1
{
public:
static double AddThemInCPP(double d1, double d2)
{
return d1 + d2;
}
};
}
You compile to a .dll and use with ExcelDna as you would use a
C# .dll, with an ExternalLibrary entry in your .dna file.
Hope this makes sense.
--Govert--