1. Use Platform Invoke to define the unmanaged function:
2. Use System types and the Interop Marshal will automatically convert the data from managed to unmanaged:
using namespace System::Runtime::InteropServices;
namespace MyNamespace
{
[DllImport(S"myUnmanagedDLL")] extern "C" void myUnmanagedFunction(System::Double *myDouble, System::Float *myFloat)
public __gc class MyClass
{
......
void myClassFunction() {
System::Double aDouble;
System::Float aFloat;
myUnmanagedFunction(&aDouble, &aFloat);
////etc.....
}
}
check out these pages for more info:
http://msdn.microsoft.com/library/de...LFunctions.asp http://msdn.microsoft.com/library/en...edatatypes.asp
----- JohnO wrote: -----
I am new to CppNet.
How can I pass a double or float value to Unmanaged function from Managed CppNet Program. I can pass an integer with no problem but when I try it with double or float I get the following compile error:
can not convert from __gc float * to float * can not convert from unmanaged to managed.
Thanks for your help.