#include "stdafx.h" #include <vector> using namespace std; double *ret; double* _stdcall f(int* n) { vector<double> vret; int i=0; do { vret.push_back(i); i++; } while (the condition to stop this loop); *n=i; ret = new double[*n]; for (i=0;i<*n;i++) ret[i]=vret[i]; return ret; }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowForm { public partial class Form1 : Form { [DllImport("DllForTest.dll")] public static extern double[] f(ref int n); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int n=0; double[] x; x = f(ref n); MessageBox.Show("x[0]= " + x[0]); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)