Код: Выделить всё
using System.Runtime.InteropServices;
namespace CommonTest
{
[ComVisible(true)]
public interface ICommonTest
{
[DispId(1)]
int Test(int a, int b);
}
[ComVisible(true)]
public class CommonTestManaged : ICommonTest
{
///
/// A method to test the creation of a managed DLL built in C#. It's functionality just adds together two numbers.
///
///
Number 1
/// Number 2
/// The sum of numbers a and b
public int Test(int a, int b)
{
return a + b;
}
}
}
Код: Выделить всё
void Usage()
{
CoInitialize(nullptr);
ICommonTestPtr pICommonTest(__uuidof(CommonTestManaged));
long lResult = 0;
pICommonTest->Test(5, 10, &lResult);
CoUninitialize();
}
Подробнее здесь: https://stackoverflow.com/questions/781 ... om-interop
Мобильная версия