C # calls C + + when using pointers to pass

Source: Internet
Author: User

Http://www.cnblogs.com/warensoft/archive/2011/12/09/warenosoft3d.html

The above article is a good explanation.

Simply record:

1. Notice that the DLL must be placed under the bin directory, otherwise you will not be prompted to find it. If you use a pointer to use the UNSAFE keyword, declare a DLL open function function name, parameters to keep.

[DllImport ("Dll_test.dll", CallingConvention = callingconvention.cdecl, CharSet = CharSet.Unicode)]
Public unsafe static extern void Initqrsdet (int pack_min);

[DllImport ("Dll_test.dll", CallingConvention = callingconvention.cdecl, CharSet = CharSet.Unicode)]
Public unsafe static extern void Find_rr_5minpack (short* in_data, int in_data_len, float* out_data, int* Out_data_len);

int outlen = 0;

float[] Outarray = new float[100000];

Fixed (short* inData = &ecgdata[0])
{
Fixed (float* outdata = &outarray[0])//Here pass an array of pointers to C # using a pointer to the keyword fixed lock integer pass the outdata pointer that adds a & sign callback is written directly to the OU Tarray array, the value of C + + callback is directly obtained by Outarray.
{
Split once in 5 minutes
Initqrsdet (5);
Find_rr_5minpack (InData, Ecgdata.length, Outdata, &outlen);
}
}

C # calls C + + when using pointers to pass

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.