المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Passing parameters from unmanaged code to managed code by reference



C# Programming
03-01-2013, 09:23 PM
Is it possible to pass parameters from unmanaged code to managed code by reference?

I am programming agents for the Metta Trader 4 (MT4) platform using MetaQuotes Language 4 (MQL4); a C like language.

Normally one would use C++ to generate DLLs but I would like to use C# if I could because when you release something in C++ it is frozen in time as opposed to when you release something in C#. With C# if problems are detected in the underlieing classes they are corrected by normal updates of the .NET platform. This is an advantage I would like to take advantage of to simplify maintenance of products I hope to sell.

I will need to pass large arrays of market data to these DLLs for analysis and would like to do this by reference.

Here is an example of how to pass an array by value:

[DllExport(EntryPoint = "SumIntegerArray")] public static int Sum([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]int[] values, int count) { int result = 0; for (int i = 0; i < count; i++) result += values; return result; } How would I pass the array by reference to the DLL?
The report of my death was an exaggeration - Mark Twain

Simply Elegant Designs JimmyRopes Designs (http://jimmyropes.com/)
Think inside the box! ProActive Secure Systems (http://proactivesecure.com/)

[I]I'm on-line therefore I am.
JimmyRopes